Skip to content

Commit

Permalink
Add setTags() api in tagController (#264)
Browse files Browse the repository at this point in the history
* Adding setTags for resources

* removing druid and cassandra containers from the functional test to avoid memory issues

* Fixing the functionalTest and addressing comments

* changing the functional test order
  • Loading branch information
zhljen committed Jun 6, 2018
1 parent 43890dd commit b4e5166
Show file tree
Hide file tree
Showing 18 changed files with 571 additions and 197 deletions.
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ hive_version=1.2.1
## Gradle Properties

org.gradle.parallel=false
org.gradle.daemon=false
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package com.netflix.metacat.client.api;

import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.TagCreateRequestDto;
import com.netflix.metacat.common.dto.TagRemoveRequestDto;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
Expand Down Expand Up @@ -126,6 +128,32 @@ Set<String> setTableTags(
Set<String> tags
);

/**
* Sets the tags on the given qualified name.
*
* @param tagCreateRequestDto tag create request dto
* @return set of tags
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
Set<String> setTags(
TagCreateRequestDto tagCreateRequestDto
);


/**
* Remove the tags on the given qualified name.
*
* @param tagRemoveRequestDto tag remove request dto
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
void removeTags(
TagRemoveRequestDto tagRemoveRequestDto
);

/**
* Remove the tags from the given table.
*
Expand All @@ -149,6 +177,6 @@ void removeTableTags(
@DefaultValue("false")
@QueryParam("all")
Boolean deleteAll,
Set<String> tags
Set<String> tags
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected AlreadyExistsException(
final boolean enableSuppression,
final boolean writableStackTrace
) {
this(name, String.format("%s '%s' already exists.", name.getType().name(), name.toString()),
this(name, String.format("%s '%s' already exists.", name.getType(), name.toString()),
cause, enableSuppression, writableStackTrace);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ default List<QualifiedName> search(
/**
* Tags the given table with the given <code>tags</code>.
*
* @param qualifiedName table name
* @param qualifiedName qualified name
* @param tags list of tags
* @param updateUserMetadata if true, updates the tags in the user metadata
* @return return the complete list of tags associated with the table
* @return return the complete list of tags associated with the resource
*/
default Set<String> setTableTags(
default Set<String> setTags(
final QualifiedName qualifiedName,
final Set<String> tags,
final boolean updateUserMetadata
Expand All @@ -95,14 +95,14 @@ default Set<String> setTableTags(
}

/**
* Removes the tags from the given table.
* Removes the tags from the given qualified name.
*
* @param qualifiedName table name
* @param deleteAll if true, will delete all tags associated with the given table
* @param tags list of tags to be removed for the given table
* @param deleteAll if true, will delete all tags associated with the given qualified name
* @param tags list of tags to be removed for the given qualified name
* @param updateUserMetadata if true, updates the tags in the user metadata
*/
default void removeTableTags(
default void removeTags(
final QualifiedName qualifiedName,
final Boolean deleteAll,
@Nullable final Set<String> tags,
Expand All @@ -113,18 +113,18 @@ default void removeTableTags(
/**
* Delete the tag item along with its associated tags.
*
* @param name table name
* @param name qualified name
* @param updateUserMetadata if true, updates the tags in the user metadata
*/
default void delete(final QualifiedName name, final boolean updateUserMetadata) {
}

/**
* Renames the tag item name with the new table name.
*
* Can only be used in table rename
* @param name table qualified name
* @param newTableName new table name
*/
default void rename(final QualifiedName name, final String newTableName) {
default void renameTableTags(final QualifiedName name, final String newTableName) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public static QualifiedName fromString(@NonNull final String s, final boolean is

/**
* Returns a copy of this qualified name with the database/table/view names in upper case.
*
* @return QualifiedName
*/
public QualifiedName cloneWithUpperCase() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2018 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.netflix.metacat.common.dto;

import com.netflix.metacat.common.QualifiedName;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.List;

/**
* Tag Create Request Dto.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class TagCreateRequestDto extends BaseDto {
private static final long serialVersionUID = -990374882621118670L;
@ApiModelProperty(value = "The qualified name", required = true)
private QualifiedName name;

@ApiModelProperty(value = "Tags to insert")
private List<String> tags;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2018 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.netflix.metacat.common.dto;

import com.netflix.metacat.common.QualifiedName;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.List;

/**
* Tag Remove Request Dto.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class TagRemoveRequestDto extends BaseDto {
private static final long serialVersionUID = 8698531483258796673L;
@ApiModelProperty(value = "The qualified name", required = true)
private QualifiedName name;

@ApiModelProperty(value = "True to delete all tags")
private Boolean deleteAll;

@ApiModelProperty(value = "Tags to remove")
private List<String> tags;
}

This file was deleted.

26 changes: 4 additions & 22 deletions metacat-functional-tests/metacat-test-cluster/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ services:
- hive-metastore
- hive-metastore-db
- postgresql
- cassandra
ports:
- '8080'
- '8000'
Expand Down Expand Up @@ -53,29 +52,14 @@ services:
-Dmetacat.mysqlmetadataservice.enabled=true
-Dmetacat.type.converter=com.netflix.metacat.connector.pig.converters.PigTypeConverter
-Dmetacat.definition.metadata.delete.enableForTable=false
-Dmetacat.definition.metadata.delete.enableDeleteForQualifiedNames=hive-metastore/hsmoke_ddb,hive-metastore/hsmoke_ddb1/test_create_table1,cassandra-310,embedded-hive-metastore,embedded-fast-hive-metastore/fsmoke_db1,embedded-fast-hive-metastore/fsmoke_ddb1,embedded-fast-hive-metastore/shard,s3-mysql-db,mysql-56-db
-Dmetacat.definition.metadata.delete.enableDeleteForQualifiedNames=hive-metastore/hsmoke_ddb,hive-metastore/hsmoke_ddb1/test_create_table1,embedded-hive-metastore,embedded-fast-hive-metastore/fsmoke_db1,embedded-fast-hive-metastore/fsmoke_ddb1,embedded-fast-hive-metastore/shard,embedded-fast-hive-metastore/fsmoke_db4,s3-mysql-db,mysql-56-db
-Dmetacat.hive.metastore.batchSize=10
-Dmetacat.usermetadata.config.location=/etc/metacat/usermetadata.properties'
labels:
- "com.netflix.metacat.oss.test"
- "com.netflix.metacat.oss.test.war"
cassandra:
image: cassandra:3.10
volumes:
- ./datastores/cassandra/:/init
labels:
- "com.netflix.metacat.oss.test"
environment:
JVM_OPTS: '-Xms256M -Xmx1024M'
druid:
hostname: druidserver
image: druidio/example-cluster
mem_limit: 384m
expose:
- '8082'
- '8081'
labels:
- "com.netflix.metacat.oss.test"
##REMOVED cassandra and druid container to reduce the memory demand (orig git hash 43890dd)
##TODO: We need to add them back with light images
hive-metastore-db:
image: mysql:5.6
volumes:
Expand Down Expand Up @@ -116,10 +100,8 @@ services:
depends_on:
- hive-metastore-db
- postgresql
- cassandra
- druid
environment:
- TARGETS=postgresql:5432,cassandra:9042,hive-metastore-db:3306,druid:8081
- TARGETS=postgresql:5432,hive-metastore-db:3306
labels:
- "com.netflix.metacat.oss.test"
service-barrier:
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit b4e5166

Please sign in to comment.