index
int64 0
0
| repo_id
stringlengths 9
205
| file_path
stringlengths 31
246
| content
stringlengths 1
12.2M
| __index_level_0__
int64 0
10k
|
---|---|---|---|---|
0 |
Create_ds/metacat/metacat-connector-postgresql/src/main/java/com/netflix/metacat/connector
|
Create_ds/metacat/metacat-connector-postgresql/src/main/java/com/netflix/metacat/connector/postgresql/package-info.java
|
/*
*
* Copyright 2017 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://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.
*
*/
/**
* Classes related to creating a connector for PostgreSQL for Metacat.
*
* @author tgianos
* @since 1.0.0
*/
package com.netflix.metacat.connector.postgresql;
| 1,800 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/package-info.java
|
/*
*
* Copyright 2016 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://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.
*
*/
/**
* Common server classes.
*
* @author amajumdar
*/
@ParametersAreNonnullByDefault
package com.netflix.metacat.common.server;
import javax.annotation.ParametersAreNonnullByDefault;
| 1,801 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/SpringConnectorFactory.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.StandardEnvironment;
/**
* Spring based Connector Factory.
*
* @author zhenl
* @since 1.1.0
*/
public abstract class SpringConnectorFactory implements ConnectorFactory {
protected final AnnotationConfigApplicationContext ctx;
private final String catalogName;
private final String catalogShardName;
/**
* Constructor.
*
* @param connectorInfoConverter connector info converter
* @param connectorContext connector related config
*/
public SpringConnectorFactory(final ConnectorInfoConverter connectorInfoConverter,
final ConnectorContext connectorContext) {
this.catalogName = connectorContext.getCatalogName();
this.catalogShardName = connectorContext.getCatalogShardName();
this.ctx = new AnnotationConfigApplicationContext();
this.ctx.setEnvironment(new StandardEnvironment());
this.ctx.getBeanFactory().registerSingleton("ConnectorContext", connectorContext);
this.ctx.getBeanFactory().registerSingleton("ConnectorInfoConverter", connectorInfoConverter);
}
/**
* registerclasses to context.
* Known issue: can not register the two beans that are the same class but have different qualifiers
* @param clazz classes object.
*/
protected void registerClazz(final Class<?>... clazz) {
this.ctx.register(clazz);
}
/**
* Add property source to env.
*
* @param properties Property source for enviroment.
*/
protected void addEnvProperties(final MapPropertySource properties) {
this.ctx.getEnvironment().getPropertySources().addFirst(properties);
}
/**
* refresh the context.
*/
public void refresh() {
this.ctx.refresh();
}
/**
* {@inheritDoc}
*/
@Override
public void stop() {
this.ctx.close();
}
/**
* {@inheritDoc}
*/
@Override
public String getCatalogName() {
return this.catalogName;
}
/**
* {@inheritDoc}
*/
@Override
public String getCatalogShardName() {
return catalogShardName;
}
}
| 1,802 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorPlugin.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
/**
* Plugin interface implemented by Connectors.
*
* @author amajumdar
* @since 1.0.0
*/
public interface ConnectorPlugin {
/**
* Returns the type of the plugin.
*
* @return Returns the type of the plugin.
*/
String getType();
/**
* Returns the service implementation for the type.
*
* @param connectorContext registry for spectator
* @return connector factory
*/
ConnectorFactory create(ConnectorContext connectorContext);
/**
* Returns the type convertor of the connector.
*
* @return Returns the type convertor of the connector.
*/
ConnectorTypeConverter getTypeConverter();
/**
* Returns the dto converter implementation of the connector.
*
* @return Returns the dto converter implementation of the connector.
*/
default ConnectorInfoConverter getInfoConverter() {
return new ConnectorInfoConverter() {
};
}
}
| 1,803 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorFactoryDecorator.java
|
package com.netflix.metacat.common.server.connectors;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiter;
import lombok.Getter;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
/**
* A decorator for a connector factory to add additional cross-cutting functionality
* to all connector services.
*/
@Slf4j
public class ConnectorFactoryDecorator implements ConnectorFactory {
private final ConnectorPlugin connectorPlugin;
@Getter
private final ConnectorFactory delegate;
private final ConnectorContext connectorContext;
private final RateLimiter rateLimiter;
private final boolean rateLimiterEnabled;
/**
* Creates the decorated connector factory that wraps connector services
* with additional wrappers.
*
* @param connectorPlugin the underlying plugin
* @param connectorContext the connector context for the underlying plugin
*/
public ConnectorFactoryDecorator(@NonNull final ConnectorPlugin connectorPlugin,
@NonNull final ConnectorContext connectorContext) {
this.connectorPlugin = connectorPlugin;
this.delegate = connectorPlugin.create(connectorContext);
this.connectorContext = connectorContext;
this.rateLimiter = connectorContext.getApplicationContext().getBean(RateLimiter.class);
// we can cache this config at startup since this is the connector level config
// that does not change later. Actual decision to enable and enforce throttling
// is in the rate limiter implementation which is more dynamic and accommodates
// changes from the Metacat dynamic configuration.
this.rateLimiterEnabled = isRateLimiterEnabled();
}
@Override
public ConnectorCatalogService getCatalogService() {
ConnectorCatalogService service = delegate.getCatalogService();
if (rateLimiterEnabled) {
log.info("Creating rate-limited connector catalog services for connector-type: {}, "
+ "plugin-type: {}, catalog: {}, shard: {}",
connectorContext.getConnectorType(), connectorPlugin.getType(),
connectorContext.getCatalogName(), connectorContext.getCatalogShardName());
service = new ThrottlingConnectorCatalogService(service, rateLimiter);
}
return service;
}
@Override
public ConnectorDatabaseService getDatabaseService() {
ConnectorDatabaseService service = delegate.getDatabaseService();
if (rateLimiterEnabled) {
log.info("Creating rate-limited connector database services for connector-type: {}, "
+ "plugin-type: {}, catalog: {}, shard: {}",
connectorContext.getConnectorType(), connectorPlugin.getType(),
connectorContext.getCatalogName(), connectorContext.getCatalogShardName());
service = new ThrottlingConnectorDatabaseService(service, rateLimiter);
}
return service;
}
@Override
public ConnectorTableService getTableService() {
ConnectorTableService service = delegate.getTableService();
if (rateLimiterEnabled) {
log.info("Creating rate-limited connector table services for connector-type: {}, "
+ "plugin-type: {}, catalog: {}, shard: {}",
connectorContext.getConnectorType(), connectorPlugin.getType(),
connectorContext.getCatalogName(), connectorContext.getCatalogShardName());
service = new ThrottlingConnectorTableService(service, rateLimiter);
}
return service;
}
@Override
public ConnectorPartitionService getPartitionService() {
ConnectorPartitionService service = delegate.getPartitionService();
if (rateLimiterEnabled) {
log.info("Creating rate-limited connector partition services for connector-type: {}, "
+ "plugin-type: {}, catalog: {}, shard: {}",
connectorContext.getConnectorType(), connectorPlugin.getType(),
connectorContext.getCatalogName(), connectorContext.getCatalogShardName());
service = new ThrottlingConnectorPartitionService(service, rateLimiter);
}
return service;
}
@Override
public String getCatalogName() {
return delegate.getCatalogName();
}
@Override
public String getCatalogShardName() {
return delegate.getCatalogShardName();
}
@Override
public void stop() {
delegate.stop();
}
private boolean isRateLimiterEnabled() {
if (connectorContext.getConfiguration() == null) {
return true;
}
return !Boolean.parseBoolean(
connectorContext.getConfiguration().getOrDefault("connector.rate-limiter-exempted", "false")
);
}
}
| 1,804 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorDatabaseService.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.server.connectors.model.DatabaseInfo;
import java.util.List;
/**
* Interfaces for manipulating database information for this connector.
*
* @author tgianos
* @since 1.0.0
*/
public interface ConnectorDatabaseService extends ConnectorBaseService<DatabaseInfo> {
/**
* Returns a list of view names for database identified by <code>name</code>.
*
* @param context The request context
* @param databaseName The name of the database under which to list resources of type <code>T</code>
* @return A list of view qualified names
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default List<QualifiedName> listViewNames(
final ConnectorRequestContext context,
final QualifiedName databaseName
) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
}
| 1,805 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ThrottlingConnectorDatabaseService.java
|
package com.netflix.metacat.common.server.connectors;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.Pageable;
import com.netflix.metacat.common.dto.Sort;
import com.netflix.metacat.common.exception.MetacatTooManyRequestsException;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiter;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiterRequestContext;
import com.netflix.metacat.common.server.connectors.model.DatabaseInfo;
import com.netflix.metacat.common.server.util.MetacatContextManager;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
import java.util.List;
/**
* Connector that throttles calls to the connector based on the contextual request name
* and the resource. Not all APIs can be throttles since we may not have a resource
* but those are a small monitory
*/
@Slf4j
@RequiredArgsConstructor
public class ThrottlingConnectorDatabaseService implements ConnectorDatabaseService {
@Getter
@NonNull
private final ConnectorDatabaseService delegate;
@NonNull
private final RateLimiter rateLimiter;
@Override
public void create(final ConnectorRequestContext context, final DatabaseInfo resource) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), resource.getName());
delegate.create(context, resource);
}
@Override
public void update(final ConnectorRequestContext context, final DatabaseInfo resource) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), resource.getName());
delegate.update(context, resource);
}
@Override
public void delete(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
delegate.delete(context, name);
}
@Override
public DatabaseInfo get(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.get(context, name);
}
@Override
@SuppressFBWarnings
public boolean exists(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.exists(context, name);
}
@Override
public List<DatabaseInfo> list(final ConnectorRequestContext context, final QualifiedName name,
@Nullable final QualifiedName prefix, @Nullable final Sort sort,
@Nullable final Pageable pageable) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.list(context, name, prefix, sort, pageable);
}
@Override
public List<QualifiedName> listNames(final ConnectorRequestContext context, final QualifiedName name,
@Nullable final QualifiedName prefix, @Nullable final Sort sort,
@Nullable final Pageable pageable) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.listNames(context, name, prefix, sort, pageable);
}
@Override
public void rename(final ConnectorRequestContext context, final QualifiedName oldName,
final QualifiedName newName) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), oldName);
delegate.rename(context, oldName, newName);
}
@Override
public List<QualifiedName> listViewNames(final ConnectorRequestContext context, final QualifiedName databaseName) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), databaseName);
return delegate.listViewNames(context, databaseName);
}
private void checkThrottling(final String requestName, final QualifiedName resource) {
if (rateLimiter.hasExceededRequestLimit(new RateLimiterRequestContext(requestName, resource))) {
final String errorMsg = String.format("Too many requests for resource %s. Request: %s",
resource, requestName);
log.warn(errorMsg);
throw new MetacatTooManyRequestsException(errorMsg);
}
}
@Override
public boolean equals(final Object o) {
return delegate.equals(o);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
}
| 1,806 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorTypeConverter.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.netflix.metacat.common.json.MetacatJsonLocator;
import com.netflix.metacat.common.type.CharType;
import com.netflix.metacat.common.type.DecimalType;
import com.netflix.metacat.common.type.MapType;
import com.netflix.metacat.common.type.ParametricType;
import com.netflix.metacat.common.type.RowType;
import com.netflix.metacat.common.type.Type;
import com.netflix.metacat.common.type.TypeEnum;
import com.netflix.metacat.common.type.VarbinaryType;
import com.netflix.metacat.common.type.VarcharType;
/**
* Canonical type converter class.
*
* @author tgianos
* @author zhenl
* @since 1.0.0
*/
public interface ConnectorTypeConverter {
/**
* Converts to metacat type.
*
* @param type type
* @return metacat type
*/
Type toMetacatType(String type);
/**
* Converts from metacat type.
*
* @param type type
* @return connector type
*/
String fromMetacatType(Type type);
/**
* Converts from Metacat type to JSON format.
* @param type type
* @return Type in JSON format
*/
default JsonNode fromMetacatTypeToJson(Type type) {
final MetacatJsonLocator json = new MetacatJsonLocator();
JsonNode result = null;
final TypeEnum base = type.getTypeSignature().getBase();
if (!base.isParametricType()) {
result = new TextNode(fromMetacatType(type));
} else if (type instanceof DecimalType || type instanceof CharType
|| type instanceof VarcharType || type instanceof VarbinaryType) {
final ObjectNode node = json.emptyObjectNode();
final String typeText = fromMetacatType(type);
final int index = typeText.indexOf('(');
if (index == -1) {
node.put("type", typeText);
} else {
node.put("type", typeText.substring(0, index));
if (type instanceof DecimalType) {
node.put("precision", ((DecimalType) type).getPrecision());
node.put("scale", ((DecimalType) type).getScale());
} else if (type instanceof CharType) {
node.put("length", ((CharType) type).getLength());
} else if (type instanceof VarcharType) {
node.put("length", ((VarcharType) type).getLength());
} else {
node.put("length", ((VarbinaryType) type).getLength());
}
}
result = node;
} else if (base.equals(TypeEnum.MAP)) {
final MapType mapType = (MapType) type;
final ObjectNode node = json.emptyObjectNode();
node.put("type", TypeEnum.MAP.getType());
node.set("keyType", fromMetacatTypeToJson(mapType.getKeyType()));
node.set("valueType", fromMetacatTypeToJson(mapType.getValueType()));
result = node;
} else if (base.equals(TypeEnum.ROW)) {
final RowType rowType = (RowType) type;
final ObjectNode node = json.emptyObjectNode();
final ArrayNode fieldsNode = node.arrayNode();
rowType.getFields().forEach(f -> {
final ObjectNode fieldNode = json.emptyObjectNode();
fieldNode.put("name", f.getName());
fieldNode.set("type", fromMetacatTypeToJson(f.getType()));
fieldsNode.add(fieldNode);
});
node.put("type", TypeEnum.ROW.getType());
node.set("fields", fieldsNode);
result = node;
} else if (base.equals(TypeEnum.ARRAY)) {
final ObjectNode node = json.emptyObjectNode();
node.put("type", TypeEnum.ARRAY.getType());
((ParametricType) type).getParameters().stream().findFirst()
.ifPresent(t -> node.set("elementType", fromMetacatTypeToJson(t)));
result = node;
}
return result;
}
}
| 1,807 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorBaseService.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.Pageable;
import com.netflix.metacat.common.dto.Sort;
import com.netflix.metacat.common.server.connectors.exception.NotFoundException;
import com.netflix.metacat.common.server.connectors.model.BaseInfo;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import javax.annotation.Nullable;
import java.util.List;
/**
* Generic interface for methods pertaining to resources from connectors such as Databases, Tables and Partitions.
*
* @param <T> The Type of resource this interface works for
* @author tgianos
* @since 1.0.0
*/
public interface ConnectorBaseService<T extends BaseInfo> {
/**
* Standard error message for all default implementations.
*/
String UNSUPPORTED_MESSAGE = "Not implemented for this connector";
/**
* Create a resource.
*
* @param context The request context
* @param resource The resource metadata
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default void create(final ConnectorRequestContext context, final T resource) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Update a resource with the given metadata.
*
* @param context The request context
* @param resource resource metadata
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default void update(final ConnectorRequestContext context, final T resource) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Delete a database with the given qualified name.
*
* @param context The request context
* @param name The qualified name of the resource to delete
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default void delete(final ConnectorRequestContext context, final QualifiedName name) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Return a resource with the given name.
*
* @param context The request context
* @param name The qualified name of the resource to get
* @return The resource metadata.
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default T get(final ConnectorRequestContext context, final QualifiedName name) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Return true, if the resource exists.
*
* @param context The request context
* @param name The qualified name of the resource to get
* @return Return true, if the resource exists.
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
@SuppressFBWarnings
default boolean exists(final ConnectorRequestContext context, final QualifiedName name) {
boolean result = false;
try {
result = get(context, name) != null;
} catch (NotFoundException ignored) {
// name does not exists.
}
return result;
}
/**
* Get a list of all the resources under the given resource identified by <code>name</code>. Optionally sort by
* <code>sort</code> and add pagination via <code>pageable</code>.
*
* @param context The request context
* @param name The name of the resource under which to list resources of type <code>T</code>
* @param prefix The optional prefix to apply to filter resources for listing
* @param sort Optional sorting parameters
* @param pageable Optional paging parameters
* @return A list of type <code>T</code> resources in the desired order if required
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default List<T> list(
final ConnectorRequestContext context,
final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort,
@Nullable final Pageable pageable
) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Returns a list of qualified names of resources under the resource identified by <code>name</code>.
*
* @param context The request context
* @param name The name of the resource under which to list resources of type <code>T</code>
* @param prefix The optional prefix to apply to filter resources for listing
* @param sort Optional sorting parameters
* @param pageable Optional paging parameters
* @return A list of Qualified Names of resources in the desired order if required
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default List<QualifiedName> listNames(
final ConnectorRequestContext context,
final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort,
@Nullable final Pageable pageable
) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Rename the specified resource.
*
* @param context The metacat request context
* @param oldName The current resource name
* @param newName The new resource name
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default void rename(
final ConnectorRequestContext context,
final QualifiedName oldName,
final QualifiedName newName
) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
}
| 1,808 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorCatalogService.java
|
/*
*
* Copyright 2019 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://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.server.connectors;
import com.netflix.metacat.common.server.connectors.model.CatalogInfo;
/**
* Interfaces for manipulating catalog information for this connector.
*
* @author rveeramacheneni
* @since 1.3.0
*/
public interface ConnectorCatalogService extends ConnectorBaseService<CatalogInfo> {
}
| 1,809 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorUtils.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.netflix.metacat.common.dto.Pageable;
import com.netflix.metacat.common.dto.Sort;
import javax.annotation.Nullable;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Utility methods shared by all Connectors.
*
* @author tgianos
* @since 1.0.0
*/
public class ConnectorUtils {
/**
* The key which a user can set a value in a catalog to override the default database service class.
*/
private static final String DATABASE_SERVICE_CLASS_KEY = "metacat.connector.databaseService.class";
/**
* The key which a user can set a value in a catalog to override the default table service class.
*/
private static final String TABLE_SERVICE_CLASS_KEY = "metacat.connector.tableService.class";
/**
* The key which a user can set a value in a catalog to override the default partition service class.
*/
private static final String PARTITION_SERVICE_CLASS_KEY = "metacat.connector.partitionService.class";
/**
* Protected constructor for utility class.
*/
protected ConnectorUtils() {
}
/**
* Sort the Qualified Names using the comparator in the desired order.
*
* @param <T> The type of elements to sort
* @param elements The list to sort
* @param sort The sort object defining ascending or descending order
* @param comparator The comparator to use
*/
public static <T> void sort(
final List<T> elements,
final Sort sort,
final Comparator<T> comparator
) {
switch (sort.getOrder()) {
case DESC:
elements.sort(comparator.reversed());
break;
case ASC:
default:
elements.sort(comparator);
}
}
/**
* If the user desires pagination this method will take the list and break it up into the correct chunk. If not it
* will return the whole list.
*
* @param <T> The type of elements to paginate
* @param elements The elements to paginate
* @param pageable The pagination parameters or null if no pagination required
* @return The final list of qualified names
*/
public static <T> List<T> paginate(
final List<T> elements,
@Nullable final Pageable pageable
) {
final ImmutableList.Builder<T> results = ImmutableList.builder();
if (pageable != null && pageable.isPageable()) {
results.addAll(
elements
.stream()
.skip(pageable.getOffset())
.limit(pageable.getLimit())
.collect(Collectors.toList())
);
} else {
results.addAll(elements);
}
return results.build();
}
/**
* Get the database service class to use.
*
* @param configuration The connector configuration
* @param defaultServiceClass The default class to use if an override is not found
* @return The database service class to use.
*/
public static Class<? extends ConnectorDatabaseService> getDatabaseServiceClass(
final Map<String, String> configuration,
final Class<? extends ConnectorDatabaseService> defaultServiceClass
) {
if (configuration.containsKey(DATABASE_SERVICE_CLASS_KEY)) {
final String className = configuration.get(DATABASE_SERVICE_CLASS_KEY);
return getServiceClass(className, ConnectorDatabaseService.class);
} else {
return defaultServiceClass;
}
}
/**
* Get the table service class to use.
*
* @param configuration The connector configuration
* @param defaultServiceClass The default class to use if an override is not found
* @return The table service class to use.
*/
public static Class<? extends ConnectorTableService> getTableServiceClass(
final Map<String, String> configuration,
final Class<? extends ConnectorTableService> defaultServiceClass
) {
if (configuration.containsKey(TABLE_SERVICE_CLASS_KEY)) {
final String className = configuration.get(TABLE_SERVICE_CLASS_KEY);
return getServiceClass(className, ConnectorTableService.class);
} else {
return defaultServiceClass;
}
}
/**
* Get the partition service class to use.
*
* @param configuration The connector configuration
* @param defaultServiceClass The default class to use if an override is not found
* @return The partition service class to use.
*/
public static Class<? extends ConnectorPartitionService> getPartitionServiceClass(
final Map<String, String> configuration,
final Class<? extends ConnectorPartitionService> defaultServiceClass
) {
if (configuration.containsKey(PARTITION_SERVICE_CLASS_KEY)) {
final String className = configuration.get(PARTITION_SERVICE_CLASS_KEY);
return getServiceClass(className, ConnectorPartitionService.class);
} else {
return defaultServiceClass;
}
}
private static <S extends ConnectorBaseService> Class<? extends S> getServiceClass(
final String className,
final Class<? extends S> baseClass
) {
try {
return Class.forName(className).asSubclass(baseClass);
} catch (final ClassNotFoundException cnfe) {
throw Throwables.propagate(cnfe);
}
}
}
| 1,810 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/DefaultConnectorFactory.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
/**
* Common connector factory with repeatable functionality.
*
* @author tgianos
* @since 1.0.0
*/
@Slf4j
@Getter
public class DefaultConnectorFactory implements ConnectorFactory {
private final String catalogName;
private final String catalogShardName;
private final Injector injector;
/**
* Constructor.
*
* @param catalogName catalog name
* @param catalogShardName catalog shard name
* @param modules The connector modules to create
*/
public DefaultConnectorFactory(
final String catalogName,
final String catalogShardName,
final Iterable<? extends Module> modules
) {
log.info("Creating connector factory for catalog {}", catalogName);
this.catalogName = catalogName;
this.catalogShardName = catalogShardName;
this.injector = Guice.createInjector(modules);
}
/**
* {@inheritDoc}
*/
@Override
public ConnectorDatabaseService getDatabaseService() {
return this.getService(ConnectorDatabaseService.class);
}
/**
* {@inheritDoc}
*/
@Override
public ConnectorTableService getTableService() {
return this.getService(ConnectorTableService.class);
}
/**
* {@inheritDoc}
*/
@Override
public ConnectorPartitionService getPartitionService() {
return this.getService(ConnectorPartitionService.class);
}
/**
* {@inheritDoc}
*/
@Override
public void stop() {
}
private <T extends ConnectorBaseService> T getService(final Class<T> serviceClass) {
final T service = this.injector.getInstance(serviceClass);
if (service != null) {
return service;
} else {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
}
}
| 1,811 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorRequestContext.java
|
/*
*
* Copyright 2016 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://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.server.connectors;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The context of the request to Metacat.
*
* @author amajumdar
* @author tgianos
* @since 1.0.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ConnectorRequestContext {
private long timestamp;
private String userName;
private boolean includeMetadata;
private boolean includeMetadataLocationOnly;
//TODO: Move this to a response object.
private boolean ignoreErrorsAfterUpdate;
}
| 1,812 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorPartitionService.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.server.connectors.model.PartitionInfo;
import com.netflix.metacat.common.server.connectors.model.PartitionListRequest;
import com.netflix.metacat.common.server.connectors.model.PartitionsSaveRequest;
import com.netflix.metacat.common.server.connectors.model.PartitionsSaveResponse;
import com.netflix.metacat.common.server.connectors.model.TableInfo;
import java.util.List;
import java.util.Map;
/**
* Interfaces for manipulating partition information for this connector.
*
* @author tgianos
* @since 1.0.0
*/
public interface ConnectorPartitionService extends ConnectorBaseService<PartitionInfo> {
/**
* Gets the Partitions based on a filter expression for the specified table.
*
* @param context The Metacat request context
* @param table table handle to get partition for
* @param partitionsRequest The metadata for what kind of partitions to get from the table
* @param tableInfo Table info object
* @return filtered list of partitions
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default List<PartitionInfo> getPartitions(
final ConnectorRequestContext context,
final QualifiedName table,
final PartitionListRequest partitionsRequest,
final TableInfo tableInfo) {
throw new UnsupportedOperationException(ConnectorBaseService.UNSUPPORTED_MESSAGE);
}
/**
* Add/Update/delete partitions for a table.
*
* @param context The Metacat request context
* @param table table handle to get partition for
* @param partitionsSaveRequest Partitions to save, alter or delete
* @return added/updated list of partition names
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default PartitionsSaveResponse savePartitions(
final ConnectorRequestContext context,
final QualifiedName table,
final PartitionsSaveRequest partitionsSaveRequest
) {
throw new UnsupportedOperationException(ConnectorBaseService.UNSUPPORTED_MESSAGE);
}
/**
* Delete partitions for a table.
*
* @param context The Metacat request context
* @param tableName table name
* @param partitionNames list of partition names
* @param tableInfo table info object
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default void deletePartitions(
final ConnectorRequestContext context,
final QualifiedName tableName,
final List<String> partitionNames,
final TableInfo tableInfo
) {
throw new UnsupportedOperationException(ConnectorBaseService.UNSUPPORTED_MESSAGE);
}
/**
* Number of partitions for the given table.
*
* @param context The Metacat request context
* @param table table handle
* @param tableInfo table info object
* @return Number of partitions
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default int getPartitionCount(
final ConnectorRequestContext context,
final QualifiedName table,
final TableInfo tableInfo
) {
throw new UnsupportedOperationException(ConnectorBaseService.UNSUPPORTED_MESSAGE);
}
/**
* Returns all the partition names referring to the given <code>uris</code>.
*
* @param context The Metacat request context
* @param uris locations
* @param prefixSearch if true, we look for tables whose location starts with the given <code>uri</code>
* @return map of uri to list of partition names
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default Map<String, List<QualifiedName>> getPartitionNames(
final ConnectorRequestContext context,
final List<String> uris,
final boolean prefixSearch
) {
throw new UnsupportedOperationException(ConnectorBaseService.UNSUPPORTED_MESSAGE);
}
/**
* Gets the partition names/keys based on a filter expression for the specified table.
*
* @param context The Metacat request context
* @param table table handle to get partition for
* @param partitionsRequest The metadata for what kind of partitions to get from the table
* @param tableInfo table info object
* @return filtered list of partition names
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default List<String> getPartitionKeys(
final ConnectorRequestContext context,
final QualifiedName table,
final PartitionListRequest partitionsRequest,
final TableInfo tableInfo) {
throw new UnsupportedOperationException(ConnectorBaseService.UNSUPPORTED_MESSAGE);
}
/**
* Gets the partition uris based on a filter expression for the specified table.
*
* @param context The Metacat request context
* @param table table handle to get partition for
* @param partitionsRequest The metadata for what kind of partitions to get from the table
* @param tableInfo table info object
* @return filtered list of partition uris
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default List<String> getPartitionUris(
final ConnectorRequestContext context,
final QualifiedName table,
final PartitionListRequest partitionsRequest,
final TableInfo tableInfo
) {
throw new UnsupportedOperationException(ConnectorBaseService.UNSUPPORTED_MESSAGE);
}
}
| 1,813 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ThrottlingConnectorCatalogService.java
|
package com.netflix.metacat.common.server.connectors;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.Pageable;
import com.netflix.metacat.common.dto.Sort;
import com.netflix.metacat.common.exception.MetacatTooManyRequestsException;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiter;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiterRequestContext;
import com.netflix.metacat.common.server.connectors.model.CatalogInfo;
import com.netflix.metacat.common.server.util.MetacatContextManager;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
import java.util.List;
/**
* Connector that throttles calls to the connector based on the contextual request name
* and the resource. Not all APIs can be throttles since we may not have a resource
* but those are a small monitory
*/
@Slf4j
@RequiredArgsConstructor
public class ThrottlingConnectorCatalogService implements ConnectorCatalogService {
@Getter
@NonNull
private final ConnectorCatalogService delegate;
@NonNull
private final RateLimiter rateLimiter;
@Override
public void create(final ConnectorRequestContext context, final CatalogInfo resource) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), resource.getName());
delegate.create(context, resource);
}
@Override
public void update(final ConnectorRequestContext context, final CatalogInfo resource) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), resource.getName());
delegate.update(context, resource);
}
@Override
public void delete(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
delegate.delete(context, name);
}
@Override
public CatalogInfo get(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.get(context, name);
}
@Override
@SuppressFBWarnings
public boolean exists(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.exists(context, name);
}
@Override
public List<CatalogInfo> list(final ConnectorRequestContext context, final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort, @Nullable final Pageable pageable) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.list(context, name, prefix, sort, pageable);
}
@Override
public List<QualifiedName> listNames(final ConnectorRequestContext context, final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort, @Nullable final Pageable pageable) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.listNames(context, name, prefix, sort, pageable);
}
@Override
public void rename(final ConnectorRequestContext context, final QualifiedName oldName,
final QualifiedName newName) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), oldName);
delegate.rename(context, oldName, newName);
}
private void checkThrottling(final String requestName, final QualifiedName resource) {
if (rateLimiter.hasExceededRequestLimit(new RateLimiterRequestContext(requestName, resource))) {
final String errorMsg = String.format("Too many requests for resource %s. Request: %s",
resource, requestName);
log.warn(errorMsg);
throw new MetacatTooManyRequestsException(errorMsg);
}
}
@Override
public boolean equals(final Object o) {
return delegate.equals(o);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
}
| 1,814 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ThrottlingConnectorTableService.java
|
package com.netflix.metacat.common.server.connectors;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.Pageable;
import com.netflix.metacat.common.dto.Sort;
import com.netflix.metacat.common.exception.MetacatTooManyRequestsException;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiter;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiterRequestContext;
import com.netflix.metacat.common.server.connectors.model.TableInfo;
import com.netflix.metacat.common.server.util.MetacatContextManager;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
/**
* Connector that throttles calls to the connector based on the contextual request name
* and the resource. Not all APIs can be throttles since we may not have a resource
* but those are a small monitory
*/
@Slf4j
@RequiredArgsConstructor
public class ThrottlingConnectorTableService implements ConnectorTableService {
@Getter
@NonNull
private final ConnectorTableService delegate;
@NonNull
private final RateLimiter rateLimiter;
@Override
public TableInfo get(final ConnectorRequestContext context,
final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.get(context, name);
}
@Override
public Map<String, List<QualifiedName>> getTableNames(final ConnectorRequestContext context,
final List<String> uris,
final boolean prefixSearch) {
return delegate.getTableNames(context, uris, prefixSearch);
}
@Override
public List<QualifiedName> getTableNames(final ConnectorRequestContext context,
final QualifiedName name,
final String filter,
final Integer limit) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.getTableNames(context, name, filter, limit);
}
@Override
public void create(final ConnectorRequestContext context, final TableInfo resource) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), resource.getName());
delegate.create(context, resource);
}
@Override
public void update(final ConnectorRequestContext context, final TableInfo resource) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), resource.getName());
delegate.update(context, resource);
}
@Override
public void delete(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
delegate.delete(context, name);
}
@Override
@SuppressFBWarnings
public boolean exists(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.exists(context, name);
}
@Override
public List<TableInfo> list(final ConnectorRequestContext context, final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort, @Nullable final Pageable pageable) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.list(context, name, prefix, sort, pageable);
}
@Override
public List<QualifiedName> listNames(final ConnectorRequestContext context, final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort, @Nullable final Pageable pageable) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.listNames(context, name, prefix, sort, pageable);
}
@Override
public void rename(final ConnectorRequestContext context,
final QualifiedName oldName,
final QualifiedName newName) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), oldName);
delegate.rename(context, oldName, newName);
}
private void checkThrottling(final String requestName, final QualifiedName resource) {
if (rateLimiter.hasExceededRequestLimit(new RateLimiterRequestContext(requestName, resource))) {
final String errorMsg = String.format("Too many requests for resource %s. Request: %s",
resource, requestName);
log.warn(errorMsg);
throw new MetacatTooManyRequestsException(errorMsg);
}
}
@Override
public boolean equals(final Object o) {
return delegate.equals(o);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
}
| 1,815 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorInfoConverter.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.server.connectors.model.DatabaseInfo;
import com.netflix.metacat.common.server.connectors.model.PartitionInfo;
import com.netflix.metacat.common.server.connectors.model.TableInfo;
/**
* Converter that converts Metacat dtos to connector represented types and vice versa.
*
* @param <D> Connector database type
* @param <T> Connector table type
* @param <P> Connector partition type
* @author amajumdar
* @since 1.0.0
*/
public interface ConnectorInfoConverter<D, T, P> {
/**
* Standard error message for all default implementations.
*/
String UNSUPPORTED_MESSAGE = "Not supported by this connector";
/**
* Converts to DatabaseDto.
*
* @param qualifiedName qualifiedName
* @param database connector database
* @return Metacat database dto
*/
default DatabaseInfo toDatabaseInfo(final QualifiedName qualifiedName, final D database) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Converts from DatabaseDto to the connector database.
*
* @param database Metacat database dto
* @return connector database
*/
default D fromDatabaseInfo(final DatabaseInfo database) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Converts to TableDto.
*
* @param qualifiedName qualifiedName
* @param table connector table
* @return Metacat table dto
*/
default TableInfo toTableInfo(final QualifiedName qualifiedName, final T table) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Converts from TableDto to the connector table.
*
* @param table Metacat table dto
* @return connector table
*/
default T fromTableInfo(final TableInfo table) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Converts to PartitionDto.
*
* @param tableInfo tableInfo
* @param partition connector partition
* @return Metacat partition dto
*/
default PartitionInfo toPartitionInfo(final TableInfo tableInfo, final P partition) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Converts from PartitionDto to the connector partition.
*
* @param tableInfo tableInfo
* @param partition Metacat partition dto
* @return connector partition
*/
default P fromPartitionInfo(final TableInfo tableInfo, final PartitionInfo partition) {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
}
| 1,816 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorContext.java
|
/*
* Copyright 2017 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://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.server.connectors;
import com.netflix.metacat.common.server.properties.Config;
import com.netflix.spectator.api.Registry;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import org.springframework.context.ApplicationContext;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* Connector Config.
*/
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
@Data
public class ConnectorContext {
/**
* Catalog name.
*/
private final String catalogName;
/**
* Catalog shard name.
*/
private final String catalogShardName;
/**
* Connector type.
*/
private final String connectorType;
/**
* Metacat config.
*/
private final Config config;
/**
* The registry for spectator.
*/
private final Registry registry;
/**
* Main application context.
*/
private final ApplicationContext applicationContext;
/**
* Metacat catalog configuration.
*/
private final Map<String, String> configuration;
/**
* Nested connector contexts.
*/
private final List<ConnectorContext> nestedConnectorContexts;
/**
* Default Ctor.
*
* @param catalogName the catalog name.
* @param catalogShardName the catalog shard name
* @param connectorType the connector type.
* @param config the application config.
* @param registry the registry.
* @param applicationContext the application context.
* @param configuration the connector properties.
*/
public ConnectorContext(final String catalogName, final String catalogShardName, final String connectorType,
final Config config, final Registry registry,
final ApplicationContext applicationContext, final Map<String, String> configuration) {
this(catalogName, catalogShardName, connectorType, config, registry,
applicationContext, configuration, Collections.emptyList());
}
}
| 1,817 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ThrottlingConnectorPartitionService.java
|
package com.netflix.metacat.common.server.connectors;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.Pageable;
import com.netflix.metacat.common.dto.Sort;
import com.netflix.metacat.common.exception.MetacatTooManyRequestsException;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiter;
import com.netflix.metacat.common.server.api.ratelimiter.RateLimiterRequestContext;
import com.netflix.metacat.common.server.connectors.model.PartitionInfo;
import com.netflix.metacat.common.server.connectors.model.PartitionListRequest;
import com.netflix.metacat.common.server.connectors.model.PartitionsSaveRequest;
import com.netflix.metacat.common.server.connectors.model.PartitionsSaveResponse;
import com.netflix.metacat.common.server.connectors.model.TableInfo;
import com.netflix.metacat.common.server.util.MetacatContextManager;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
/**
* Connector that throttles calls to the connector based on the contextual request name
* and the resource. Not all APIs can be throttles since we may not have a resource
* but those are a small monitory
*/
@Slf4j
@RequiredArgsConstructor
public class ThrottlingConnectorPartitionService implements ConnectorPartitionService {
@Getter
@NonNull
private final ConnectorPartitionService delegate;
@NonNull
private final RateLimiter rateLimiter;
@Override
public List<PartitionInfo> getPartitions(final ConnectorRequestContext context,
final QualifiedName table,
final PartitionListRequest partitionsRequest,
final TableInfo tableInfo) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), table);
return delegate.getPartitions(context, table, partitionsRequest, tableInfo);
}
@Override
public PartitionsSaveResponse savePartitions(final ConnectorRequestContext context,
final QualifiedName table,
final PartitionsSaveRequest partitionsSaveRequest) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), table);
return delegate.savePartitions(context, table, partitionsSaveRequest);
}
@Override
public void deletePartitions(final ConnectorRequestContext context,
final QualifiedName tableName,
final List<String> partitionNames,
final TableInfo tableInfo) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), tableName);
delegate.deletePartitions(context, tableName, partitionNames, tableInfo);
}
@Override
public int getPartitionCount(final ConnectorRequestContext context,
final QualifiedName table,
final TableInfo tableInfo) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), table);
return delegate.getPartitionCount(context, table, tableInfo);
}
@Override
public Map<String, List<QualifiedName>> getPartitionNames(final ConnectorRequestContext context,
final List<String> uris,
final boolean prefixSearch) {
return delegate.getPartitionNames(context, uris, prefixSearch);
}
@Override
public List<String> getPartitionKeys(final ConnectorRequestContext context,
final QualifiedName table,
final PartitionListRequest partitionsRequest,
final TableInfo tableInfo) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), table);
return delegate.getPartitionKeys(context, table, partitionsRequest, tableInfo);
}
@Override
public List<String> getPartitionUris(final ConnectorRequestContext context,
final QualifiedName table,
final PartitionListRequest partitionsRequest,
final TableInfo tableInfo) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), table);
return delegate.getPartitionUris(context, table, partitionsRequest, tableInfo);
}
@Override
public void create(final ConnectorRequestContext context, final PartitionInfo resource) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), resource.getName());
delegate.create(context, resource);
}
@Override
public void update(final ConnectorRequestContext context, final PartitionInfo resource) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), resource.getName());
delegate.update(context, resource);
}
@Override
public void delete(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
delegate.delete(context, name);
}
@Override
public PartitionInfo get(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.get(context, name);
}
@Override
@SuppressFBWarnings
public boolean exists(final ConnectorRequestContext context, final QualifiedName name) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.exists(context, name);
}
@Override
public List<PartitionInfo> list(final ConnectorRequestContext context, final QualifiedName name,
@Nullable final QualifiedName prefix, @Nullable final Sort sort,
@Nullable final Pageable pageable) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.list(context, name, prefix, sort, pageable);
}
@Override
public List<QualifiedName> listNames(final ConnectorRequestContext context, final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort, @Nullable final Pageable pageable) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), name);
return delegate.listNames(context, name, prefix, sort, pageable);
}
@Override
public void rename(final ConnectorRequestContext context, final QualifiedName oldName,
final QualifiedName newName) {
checkThrottling(MetacatContextManager.getContext().getRequestName(), oldName);
delegate.rename(context, oldName, newName);
}
private void checkThrottling(final String requestName, final QualifiedName resource) {
if (rateLimiter.hasExceededRequestLimit(new RateLimiterRequestContext(requestName, resource))) {
final String errorMsg = String.format("Too many requests for resource %s. Request: %s",
resource, requestName);
log.warn(errorMsg);
throw new MetacatTooManyRequestsException(errorMsg);
}
}
@Override
public boolean equals(final Object o) {
return delegate.equals(o);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
}
| 1,818 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorFactory.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
/**
* Factory that returns the connector implementations of the service and converter interfaces.
*
* @author amajumdar
* @since 1.0.0
*/
public interface ConnectorFactory {
/**
* Standard error message for all default implementations.
*/
String UNSUPPORTED_MESSAGE = "Not supported by this connector";
/**
* Returns the catalog service implementation of the connector.
*
* @return Returns the catalog service implementation of the connector.
*/
default ConnectorCatalogService getCatalogService() {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Returns the database service implementation of the connector.
*
* @return Returns the database service implementation of the connector.
*/
default ConnectorDatabaseService getDatabaseService() {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Returns the table service implementation of the connector.
*
* @return Returns the table service implementation of the connector.
*/
default ConnectorTableService getTableService() {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Returns the partition service implementation of the connector.
*
* @return Returns the partition service implementation of the connector.
*/
default ConnectorPartitionService getPartitionService() {
throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
}
/**
* Returns the name of the catalog.
*
* @return Returns the name of the catalog.
*/
String getCatalogName();
/**
* Returns the name of the catalog shard.
*
* @return Returns the name of the catalog shard.
*/
String getCatalogShardName();
/**
* Shuts down the factory.
*/
void stop();
}
| 1,819 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/package-info.java
|
/*
*
* Copyright 2017 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://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.
*
*/
/**
* Classes and interfaces related to SPI (Service Provider Interface) for catalog connectors.
*
* @author tgianos
* @since 1.0.0
*/
@ParametersAreNonnullByDefault
package com.netflix.metacat.common.server.connectors;
import javax.annotation.ParametersAreNonnullByDefault;
| 1,820 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/ConnectorTableService.java
|
/*
*
* Copyright 2017 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://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.server.connectors;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.server.connectors.model.TableInfo;
import java.util.List;
import java.util.Map;
/**
* Service interface for connector to implement and expose Table related metadata.
*
* @author tgianos
* @since 1.0.0
*/
public interface ConnectorTableService extends ConnectorBaseService<TableInfo> {
/**
* Returns all the table names referring to the given <code>uris</code>.
*
* @param context The Metacat request context
* @param uris locations
* @param prefixSearch if true, we look for tables whose location starts with the given <code>uri</code>
* @return map of uri to list of partition names
* @throws UnsupportedOperationException If the connector doesn't implement this method
*/
default Map<String, List<QualifiedName>> getTableNames(
final ConnectorRequestContext context,
final List<String> uris,
final boolean prefixSearch
) {
throw new UnsupportedOperationException(ConnectorBaseService.UNSUPPORTED_MESSAGE);
}
/**
* Returns a filtered list of table names.
* @param context The Metacat request context
* @param filter filter expression
* @param name qualified name of either the catalog or database
* @param limit size of the list
* @return list of table names
*/
default List<QualifiedName> getTableNames(
final ConnectorRequestContext context,
final QualifiedName name,
final String filter,
final Integer limit) {
throw new UnsupportedOperationException(ConnectorBaseService.UNSUPPORTED_MESSAGE);
}
}
| 1,821 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/util/TimeUtil.java
|
/*
*
* Copyright 2017 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://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.server.connectors.util;
import java.util.concurrent.TimeUnit;
/**
* TimeUtil.
*
* @author zhenl
* @since 1.0.0
*/
public final class TimeUtil {
private TimeUtil() {
}
/**
* unitFor.
*
* @param inputUnit inputUnit
* @param defaultUnit defaultUnit
* @return TimeUnit
*/
public static TimeUnit unitFor(final String inputUnit, final TimeUnit defaultUnit) {
final String unit = inputUnit.trim().toLowerCase();
if (unit.isEmpty() || unit.equals("l")) {
if (defaultUnit == null) {
throw new IllegalArgumentException("Time unit is not specified");
}
return defaultUnit;
} else if (unit.equals("d") || unit.startsWith("day")) {
return TimeUnit.DAYS;
} else if (unit.equals("h") || unit.startsWith("hour")) {
return TimeUnit.HOURS;
} else if (unit.equals("m") || unit.startsWith("min")) {
return TimeUnit.MINUTES;
} else if (unit.equals("s") || unit.startsWith("sec")) {
return TimeUnit.SECONDS;
} else if (unit.equals("ms") || unit.startsWith("msec")) {
return TimeUnit.MILLISECONDS;
} else if (unit.equals("us") || unit.startsWith("usec")) {
return TimeUnit.MICROSECONDS;
} else if (unit.equals("ns") || unit.startsWith("nsec")) {
return TimeUnit.NANOSECONDS;
}
throw new IllegalArgumentException("Invalid time unit " + unit);
}
/**
* toTime.
*
* @param value value
* @param inputUnit inputUnit
* @param outUnit outUnit
* @return long
*/
public static long toTime(final String value, final TimeUnit inputUnit, final TimeUnit outUnit) {
final String[] parsed = parseTime(value.trim());
return outUnit.convert(Long.parseLong(parsed[0].trim().trim()), unitFor(parsed[1].trim(), inputUnit));
}
private static String[] parseTime(final String value) {
final char[] chars = value.toCharArray();
int i = 0;
while (i < chars.length && (chars[i] == '-' || Character.isDigit(chars[i]))) {
i++;
}
return new String[]{value.substring(0, i), value.substring(i)};
}
}
| 1,822 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/util/package-info.java
|
/*
*
* Copyright 2017 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://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.
*
*/
/**
* Connector utils.
*
* @author zhenl
* @since 1.2.0
*/
@ParametersAreNonnullByDefault
package com.netflix.metacat.common.server.connectors.util;
import javax.annotation.ParametersAreNonnullByDefault;
| 1,823 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/PartitionInfo.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.netflix.metacat.common.QualifiedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.Map;
/**
* Partition DTO.
*
* @author amajumdar, zhenl
* @since 1.0.0
*/
@SuppressWarnings("unused")
@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public final class PartitionInfo extends BaseInfo {
private StorageInfo serde;
//to populate the metrics from iceberg
private ObjectNode dataMetrics;
/**
* Constructor.
*
* @param name name of the partition
* @param auditInfo audit information of the partition
* @param metadata metadata of the partition.
* @param serde storage info of the partition
*/
@Builder
private PartitionInfo(
final QualifiedName name,
final AuditInfo auditInfo,
final Map<String, String> metadata,
final StorageInfo serde,
final ObjectNode dataMetrics
) {
super(name, auditInfo, metadata);
this.serde = serde;
this.dataMetrics = dataMetrics;
}
}
| 1,824 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/FieldInfo.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import com.netflix.metacat.common.type.Type;
import com.netflix.metacat.common.type.TypeRegistry;
import com.netflix.metacat.common.type.TypeSignature;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
* Field DTO.
*
* @author amajumdar
* @since 1.0.0
*/
@ApiModel(value = "Table field/column metadata")
@SuppressWarnings("unused")
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@Builder
@AllArgsConstructor
public final class FieldInfo implements Serializable {
private static final long serialVersionUID = -762764635047711004L;
private String comment;
private String name;
private boolean partitionKey;
private String sourceType;
private transient Type type;
private Boolean isNullable;
private Integer size;
private String defaultValue;
private Boolean isSortKey;
private Boolean isIndexKey;
// setters and getters
private void writeObject(final ObjectOutputStream oos)
throws IOException {
oos.defaultWriteObject();
oos.writeObject(type == null ? null : type.getDisplayName());
}
private void readObject(final ObjectInputStream ois)
throws ClassNotFoundException, IOException {
ois.defaultReadObject();
final Object oSignature = ois.readObject();
if (oSignature != null) {
final String signatureString = (String) oSignature;
if (StringUtils.isNotBlank(signatureString)) {
final TypeSignature signature = TypeSignature.parseTypeSignature(signatureString);
this.setType((TypeRegistry.getTypeRegistry().getType(signature)));
}
}
}
}
| 1,825 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/ClusterInfo.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* Cluster information.
*
* @author amajumdar
* @since 1.3.0
*/
@SuppressWarnings("unused")
@Data
@EqualsAndHashCode(callSuper = false)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ClusterInfo implements Serializable {
private static final long serialVersionUID = -3119788564952124498L;
/** Name of the cluster. */
private String name;
/** Type of the cluster. */
private String type;
/** Name of the account under which the cluster was created. Ex: "abc_test" */
private String account;
/** Id of Account under which the cluster was created. Ex: "abc_test" */
private String accountId;
/** Environment under which the cluster exists. Ex: "prod", "test" */
private String env;
/** Region in which the cluster exists. Ex: "us-east-1" */
private String region;
}
| 1,826 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/StorageInfo.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Map;
/**
* Storage Info.
*
* @author amajumdar
* @since 1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class StorageInfo implements Serializable {
private static final long serialVersionUID = -1261997541007723844L;
private String inputFormat;
private String outputFormat;
private String owner;
private Map<String, String> parameters;
private Map<String, String> serdeInfoParameters;
private String serializationLib;
private String uri;
}
| 1,827 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/PartitionListRequest.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import com.netflix.metacat.common.dto.Pageable;
import com.netflix.metacat.common.dto.Sort;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* Partition get request.
*
* @author amajumdar
* @since 1.0.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class PartitionListRequest {
private String filter;
private List<String> partitionNames;
private Boolean includePartitionDetails = false;
private Pageable pageable;
private Sort sort;
private Boolean includeAuditOnly = false;
}
| 1,828 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/CatalogInfo.java
|
package com.netflix.metacat.common.server.connectors.model;
import com.netflix.metacat.common.QualifiedName;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.Map;
/**
* Connector catalog information.
*
* @author rveeramacheneni
* @since 1.3.0
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public final class CatalogInfo extends BaseInfo {
private ClusterInfo clusterInfo;
/**
* Constructor.
* @param name qualified name of the catalog
* @param auditInfo audit info
* @param metadata metadata properties
* @param clusterInfo cluster information
*/
@Builder
private CatalogInfo(
final QualifiedName name,
final AuditInfo auditInfo,
final Map<String, String> metadata,
final ClusterInfo clusterInfo
) {
super(name, auditInfo, metadata);
this.clusterInfo = clusterInfo;
}
}
| 1,829 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/PartitionsSaveRequest.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* Partition save request.
*
* @author amajumdar
* @since 1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class PartitionsSaveRequest {
// List of partitions
private List<PartitionInfo> partitions;
// List of partition ids/names for deletes
private List<String> partitionIdsForDeletes;
// If true, we check if partition exists and drop it before adding it back. If false, we do not check and just add.
private Boolean checkIfExists = true;
// If true, we alter if partition exists. If checkIfExists=false, then this is false too.
private Boolean alterIfExists = false;
}
| 1,830 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/PartitionsSaveResponse.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.List;
/**
* Partition save response.
*
* @author amajumdar
* @since 1.0.0
*/
@Data
@Builder
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class PartitionsSaveResponse {
/**
* List of added partition names.
*/
private List<String> added;
/**
* List of updated partition names.
*/
private List<String> updated;
/**
* Default constructor.
*/
public PartitionsSaveResponse() {
added = new ArrayList<>();
updated = new ArrayList<>();
}
}
| 1,831 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/ViewInfo.java
|
/*
*
* 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://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.server.connectors.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* Hive Virtual View Info.
*
* @author zhenl
* @since 1.2.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public class ViewInfo implements Serializable {
private static final long serialVersionUID = -7841464527538892424L;
/* view original text*/
private String viewOriginalText;
/* view expanded text*/
private String viewExpandedText;
}
| 1,832 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/TableInfo.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import com.netflix.metacat.common.QualifiedName;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
/**
* Table Info.
*
* @author amajumdar
* @since 1.0.0
*/
@SuppressWarnings("checkstyle:finalclass")
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class TableInfo extends BaseInfo {
private List<FieldInfo> fields;
private StorageInfo serde;
private ViewInfo view;
/**
* Constructor.
*
* @param name name of the table
* @param auditInfo audit information of the table
* @param metadata metadata of the table.
* @param fields list of columns
* @param serde storage informations
*/
@Builder
private TableInfo(
final QualifiedName name,
final AuditInfo auditInfo,
final Map<String, String> metadata,
final List<FieldInfo> fields,
final StorageInfo serde,
final ViewInfo view
) {
super(name, auditInfo, metadata);
this.fields = fields;
this.serde = serde;
this.view = view;
}
}
| 1,833 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/DatabaseInfo.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import com.netflix.metacat.common.QualifiedName;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.Map;
/**
* Database information.
*
* @author amajumdar
* @since 1.0.0
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public final class DatabaseInfo extends BaseInfo {
/* location of the database */
private String uri;
/**
* Constructor.
*
* @param name name of the database
* @param auditInfo audit information of the database
* @param metadata metadata of the database.
* @param uri location of the database
*/
@Builder
private DatabaseInfo(
final QualifiedName name,
final AuditInfo auditInfo,
final Map<String, String> metadata,
final String uri
) {
super(name, auditInfo, metadata);
this.uri = uri;
}
}
| 1,834 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/BaseInfo.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import com.netflix.metacat.common.QualifiedName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Map;
/**
* Base class for catalog resources.
*
* @author amajumdar
* @since 1.0.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public abstract class BaseInfo implements Serializable {
private static final long serialVersionUID = 284049639636194327L;
/* Name of the resource */
private QualifiedName name;
/* Audit information of the resource */
private AuditInfo audit;
/* Metadata properties of the resource */
private Map<String, String> metadata;
}
| 1,835 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/AuditInfo.java
|
/*
*
* Copyright 2017 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://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.server.connectors.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* Audit information.
*
* @author amajumdar
* @since 1.0.0
*/
@SuppressWarnings("unused")
@Data
@EqualsAndHashCode(callSuper = false)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AuditInfo implements Serializable {
private static final long serialVersionUID = -4683417661637244309L;
/* Created By */
private String createdBy;
/* Created date */
private Date createdDate;
/* Last modified by */
private String lastModifiedBy;
/* Last modified date */
private Date lastModifiedDate;
}
| 1,836 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/model/package-info.java
|
/*
*
* Copyright 2017 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://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.
*
*/
/**
* Classes and interfaces related to model objects for catalog connectors.
*
* @author amajumdar
* @since 1.0.0
*/
package com.netflix.metacat.common.server.connectors.model;
| 1,837 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/AlreadyExistsException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import lombok.Getter;
import javax.annotation.Nullable;
/**
* Abstract not found error exception class.
*
* @author zhenl
*/
@Getter
public abstract class AlreadyExistsException extends ConnectorException {
private QualifiedName name;
protected AlreadyExistsException(final QualifiedName name) {
this(name, null);
}
protected AlreadyExistsException(final QualifiedName name, @Nullable final Throwable cause) {
this(name, cause, false, false);
}
protected AlreadyExistsException(
final QualifiedName name,
@Nullable final Throwable cause,
final boolean enableSuppression,
final boolean writableStackTrace
) {
this(name, String.format("%s '%s' already exists.", name.getType(), name.toString()),
cause, enableSuppression, writableStackTrace);
}
protected AlreadyExistsException(
final QualifiedName name,
final String message,
@Nullable final Throwable cause,
final boolean enableSuppression,
final boolean writableStackTrace
) {
super(message, cause, enableSuppression, writableStackTrace);
this.name = name;
}
}
| 1,838 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/InvalidMetadataException.java
|
/*
* 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://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.server.connectors.exception;
/**
* Invalid BusinessMetadata Exception.
* @author zhenl
* @since 1.2.0
*/
public class InvalidMetadataException extends ConnectorException {
/**
* Constructor.
*
* @param message message
*/
public InvalidMetadataException(final String message) {
super(message);
}
}
| 1,839 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/DatabaseAlreadyExistsException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import javax.annotation.Nullable;
/**
* Exception when schema already exists.
*
* @author zhenl
*/
public class DatabaseAlreadyExistsException extends AlreadyExistsException {
/**
* Constructor.
*
* @param databaseName schema name
*/
public DatabaseAlreadyExistsException(final QualifiedName databaseName) {
this(databaseName, null);
}
/**
* Constructor.
*
* @param databaseName schema name
* @param cause error cause
*/
public DatabaseAlreadyExistsException(final QualifiedName databaseName, @Nullable final Throwable cause) {
super(databaseName, cause);
}
}
| 1,840 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/PartitionAlreadyExistsException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.netflix.metacat.common.QualifiedName;
import javax.annotation.Nullable;
import java.util.List;
/**
* Exception when partition already exists.
*
* @author zhenl
*/
public class PartitionAlreadyExistsException extends AlreadyExistsException {
private static final Joiner COMMA_JOINER = Joiner.on(',');
/**
* Constructor.
*
* @param tableName table name
* @param partitionName partition name
*/
public PartitionAlreadyExistsException(final QualifiedName tableName, final String partitionName) {
this(tableName, partitionName, null);
}
/**
* Constructor.
*
* @param tableName table name
* @param partitionName partition name
* @param cause error cause
*/
public PartitionAlreadyExistsException(
final QualifiedName tableName,
final String partitionName,
@Nullable final Throwable cause
) {
this(tableName, Lists.newArrayList(partitionName), cause);
}
/**
* Constructor.
*
* @param tableName table name
* @param partitionNames partition names
* @param cause error cause
*/
public PartitionAlreadyExistsException(
final QualifiedName tableName,
final List<String> partitionNames,
@Nullable final Throwable cause
) {
super(tableName,
String.format("One or more of the partitions '%s' already exists for table '%s'",
COMMA_JOINER.join(partitionNames), tableName), cause, false, false);
}
}
| 1,841 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/TableMigrationInProgressException.java
|
package com.netflix.metacat.common.server.connectors.exception;
import com.netflix.metacat.common.exception.MetacatTooManyRequestsException;
/**
* Exception indicating that the table is currently under migration
* and cannot be modified.
*
* Extends MetacatTooManyRequestsException so users can handle a HTTP 429 error code
* to retry with a backoff until migration completes.
*/
public class TableMigrationInProgressException extends MetacatTooManyRequestsException {
/**
* Ctor.
*
* @param reason The exception message.
*/
public TableMigrationInProgressException(final String reason) {
super(reason);
}
}
| 1,842 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/TablePreconditionFailedException.java
|
/*
*
* 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import lombok.Getter;
import javax.annotation.Nullable;
/**
* Exception when table is not found.
*
* @author amajumdar
*/
@Getter
public class TablePreconditionFailedException extends ConnectorException {
// Current metadata location for the table
private final String metadataLocation;
// Provided metadata location
private final String previousMetadataLocation;
/**
* Constructor.
*
* @param name qualified name of the table
* @param message error cause
* @param metadataLocation current metadata location
* @param previousMetadataLocation previous metadata location
*/
public TablePreconditionFailedException(final QualifiedName name,
@Nullable final String message,
final String metadataLocation,
final String previousMetadataLocation) {
super(String.format("Precondition failed to update table %s. %s", name, message));
this.metadataLocation = metadataLocation;
this.previousMetadataLocation = previousMetadataLocation;
}
}
| 1,843 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/InvalidMetaException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import javax.annotation.Nullable;
/**
* Exception when the given information about an entity is invalid.
*
* @author zhenl
*/
public class InvalidMetaException extends ConnectorException {
private QualifiedName tableName;
private String partitionId;
/**
* Constructor.
*
* @param tableName table name
* @param cause error cause
*/
public InvalidMetaException(final QualifiedName tableName, @Nullable final Throwable cause) {
super(String.format("Invalid metadata for %s.", tableName), cause);
this.tableName = tableName;
}
/**
* Constructor.
*
* @param tableName table name
* @param partitionId partition name
* @param cause error cause
*/
public InvalidMetaException(final QualifiedName tableName,
final String partitionId, @Nullable final Throwable cause) {
super(String.format("Invalid metadata for %s for partition %s.", tableName, partitionId), cause);
this.tableName = tableName;
this.partitionId = partitionId;
}
/**
* Constructor.
*
* @param message error message
* @param cause error cause
*/
public InvalidMetaException(final String message, @Nullable final Throwable cause) {
super(message, cause);
}
}
| 1,844 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/ConnectorException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import javax.annotation.Nullable;
/**
* Connector exception class.
*
* @author zhenl
*/
public class ConnectorException extends RuntimeException {
/**
* Constructor.
*
* @param message message
*/
public ConnectorException(final String message) {
super(message);
}
/**
* Constructor.
*
* @param message message
* @param cause cause
*/
public ConnectorException(final String message, @Nullable final Throwable cause) {
super(message, cause);
}
/**
* Constructor.
*
* @param message message
* @param cause cause
* @param enableSuppression eable suppression
* @param writableStackTrace stacktrace
*/
public ConnectorException(
final String message,
@Nullable final Throwable cause,
final boolean enableSuppression,
final boolean writableStackTrace
) {
super(message, cause, enableSuppression, writableStackTrace);
}
/**
* {@inheritDoc}
*/
@Override
public String getMessage() {
String message = super.getMessage();
if (message == null && getCause() != null) {
message = getCause().getMessage();
}
return message;
}
}
| 1,845 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/TableAlreadyExistsException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import javax.annotation.Nullable;
/**
* Exception when schema already exists.
*
* @author zhenl
*/
public class TableAlreadyExistsException extends AlreadyExistsException {
/**
* Constructor.
*
* @param tableName table name
*/
public TableAlreadyExistsException(final QualifiedName tableName) {
this(tableName, null);
}
/**
* Constructor.
*
* @param tableName table name
* @param cause error cause
*/
public TableAlreadyExistsException(final QualifiedName tableName, @Nullable final Throwable cause) {
super(tableName, cause);
}
}
| 1,846 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/CatalogNotFoundException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import javax.annotation.Nullable;
/**
* Exception when a catalog is not found.
*
* @author zhenl
*/
public class CatalogNotFoundException extends NotFoundException {
/**
* Constructor.
*
* @param catalogName catalog name
*/
public CatalogNotFoundException(final String catalogName) {
this(catalogName, null);
}
/**
* Constructor.
*
* @param catalogName catalog name
* @param cause error cause
*/
public CatalogNotFoundException(final String catalogName, @Nullable final Throwable cause) {
super(QualifiedName.ofCatalog(catalogName), cause);
}
}
| 1,847 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/PartitionNotFoundException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import lombok.Getter;
import javax.annotation.Nullable;
/**
* Exception when partition is not found.
*
* @author zhenl
*/
@Getter
public class PartitionNotFoundException extends NotFoundException {
private final QualifiedName tableName;
private final String partitionName;
/**
* Constructor.
*
* @param tableName table name
* @param partitionName partition name
*/
public PartitionNotFoundException(final QualifiedName tableName, final String partitionName) {
this(tableName, partitionName, null);
}
/**
* Constructor.
*
* @param tableName table name
* @param partitionName partition name
* @param cause error cause
*/
public PartitionNotFoundException(
final QualifiedName tableName,
final String partitionName,
@Nullable final Throwable cause
) {
super(QualifiedName.ofPartition(tableName.getCatalogName(),
tableName.getDatabaseName(), tableName.getTableName(), partitionName),
String.format("Partition %s not found for table %s", partitionName, tableName),
cause, false, false);
this.tableName = tableName;
this.partitionName = partitionName;
}
}
| 1,848 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/DatabaseNotFoundException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import javax.annotation.Nullable;
/**
* Exception when database is not found.
*
* @author amajumdar
*/
public class DatabaseNotFoundException extends NotFoundException {
/**
* Constructor.
*
* @param name qualified name of the database
*/
public DatabaseNotFoundException(final QualifiedName name) {
super(name);
}
/**
* Constructor.
*
* @param name qualified name of the database
* @param cause error cause
*/
public DatabaseNotFoundException(final QualifiedName name, @Nullable final Throwable cause) {
super(name, cause);
}
/**
* Constructor.
*
* @param name qualified name of the database
* @param cause error cause
* @param enableSuppression enable suppression of the stacktrace
* @param writableStackTrace writable stacktrace
*/
public DatabaseNotFoundException(
final QualifiedName name,
@Nullable final Throwable cause,
final boolean enableSuppression,
final boolean writableStackTrace
) {
super(name, cause, enableSuppression, writableStackTrace);
}
}
| 1,849 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/TableNotFoundException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import javax.annotation.Nullable;
/**
* Exception when table is not found.
*
* @author amajumdar
*/
public class TableNotFoundException extends NotFoundException {
/**
* Constructor.
*
* @param name qualified name of the table
*/
public TableNotFoundException(final QualifiedName name) {
super(name);
}
/**
* Constructor.
*
* @param name qualified name of the table
* @param cause error cause
*/
public TableNotFoundException(final QualifiedName name, @Nullable final Throwable cause) {
super(name, cause);
}
/**
* Constructor.
*
* @param name qualified name of the table
* @param cause error cause
* @param enableSuppression enable suppression of the stacktrace
* @param writableStackTrace writable stacktrace
*/
public TableNotFoundException(
final QualifiedName name,
final Throwable cause,
final boolean enableSuppression,
final boolean writableStackTrace
) {
super(name, cause, enableSuppression, writableStackTrace);
}
}
| 1,850 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/NotFoundException.java
|
/*
*
* Copyright 2016 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://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.server.connectors.exception;
import com.netflix.metacat.common.QualifiedName;
import lombok.Getter;
import javax.annotation.Nullable;
/**
* Abstract not found error exception class.
*
* @author zhenl
*/
@Getter
public abstract class NotFoundException extends ConnectorException {
private QualifiedName name;
protected NotFoundException(final QualifiedName name) {
this(name, null);
}
protected NotFoundException(final QualifiedName name, @Nullable final Throwable cause) {
this(name, cause, false, false);
}
protected NotFoundException(
final QualifiedName name,
@Nullable final Throwable cause,
final boolean enableSuppression,
final boolean writableStackTrace
) {
this(name, String.format("%s '%s' not found.", name.getType().name(), name.toString()),
cause, enableSuppression, writableStackTrace);
}
protected NotFoundException(
final QualifiedName name,
final String message,
@Nullable final Throwable cause,
final boolean enableSuppression,
final boolean writableStackTrace
) {
super(message, cause, enableSuppression, writableStackTrace);
this.name = name;
}
}
| 1,851 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/connectors/exception/package-info.java
|
/*
* Copyright 2016 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://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.
*/
/**
* Exception package for Metacat connectors.
*
* @author zhenl
*/
@ParametersAreNonnullByDefault
package com.netflix.metacat.common.server.connectors.exception;
import javax.annotation.ParametersAreNonnullByDefault;
| 1,852 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/converter/DozerTypeConverter.java
|
/*
*
* Copyright 2017 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://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.server.converter;
import com.netflix.metacat.common.server.connectors.ConnectorTypeConverter;
import com.netflix.metacat.common.server.util.MetacatContextManager;
import com.netflix.metacat.common.type.Type;
import lombok.NonNull;
import org.dozer.DozerConverter;
import javax.annotation.Nonnull;
/**
* Dozer converter implementation for data types.
*
* @author amajumdar
* @author tgianos
* @since 1.0.0
*/
public class DozerTypeConverter extends DozerConverter<Type, String> {
private TypeConverterFactory typeConverterFactory;
/**
* Constructor.
*
* @param typeConverterFactory Type converter factory
*/
public DozerTypeConverter(@Nonnull @NonNull final TypeConverterFactory typeConverterFactory) {
super(Type.class, String.class);
this.typeConverterFactory = typeConverterFactory;
}
/**
* {@inheritDoc}
*/
@Override
public String convertTo(final Type source, final String destination) {
final ConnectorTypeConverter typeConverter;
try {
typeConverter = this.typeConverterFactory.get(MetacatContextManager.getContext().getDataTypeContext());
} catch (final Exception e) {
throw new IllegalStateException("Unable to get a type converter", e);
}
return typeConverter.fromMetacatType(source);
}
/**
* {@inheritDoc}
*/
@Override
public Type convertFrom(final String source, final Type destination) {
final ConnectorTypeConverter typeConverter;
try {
typeConverter = this.typeConverterFactory.get(MetacatContextManager.getContext().getDataTypeContext());
} catch (final Exception e) {
throw new IllegalStateException("Unable to get a type converter", e);
}
return typeConverter.toMetacatType(source);
}
}
| 1,853 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/converter/TypeConverterFactory.java
|
/*
*
* Copyright 2016 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://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.server.converter;
import com.google.common.collect.Maps;
import com.netflix.metacat.common.server.connectors.ConnectorTypeConverter;
import javax.annotation.Nullable;
import java.util.Map;
/**
* Type converter factory.
*
* @author amajumdar
* @author tgianos
* @since 1.0.0
*/
public class TypeConverterFactory {
private static final String METACAT_TYPE_CONTEXT = "metacat";
private Map<String, ConnectorTypeConverter> registry = Maps.newHashMap();
private ConnectorTypeConverter defaultTypeConverter;
/**
* Constructor.
*
* @param defaultTypeConverter default type converter
*/
public TypeConverterFactory(final ConnectorTypeConverter defaultTypeConverter) {
this.defaultTypeConverter = defaultTypeConverter;
this.registry.put(METACAT_TYPE_CONTEXT, new DefaultTypeConverter());
}
/**
* Adds the type converter to the registry.
*
* @param connectorType connector type
* @param typeConverter types converter
*/
public void register(final String connectorType, final ConnectorTypeConverter typeConverter) {
this.registry.put(connectorType, typeConverter);
}
/**
* Returns the right type converter based on the context.
*
* @param context context
* @return type converter
*/
public ConnectorTypeConverter get(@Nullable final String context) {
if (context == null) {
return defaultTypeConverter;
}
final ConnectorTypeConverter result = this.registry.get(context);
if (result == null) {
throw new IllegalArgumentException("No handler for " + context);
}
return result;
}
}
| 1,854 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/converter/DozerJsonTypeConverter.java
|
package com.netflix.metacat.common.server.converter;
import com.fasterxml.jackson.databind.JsonNode;
import com.netflix.metacat.common.server.connectors.ConnectorTypeConverter;
import com.netflix.metacat.common.server.util.MetacatContextManager;
import com.netflix.metacat.common.type.Type;
import lombok.NonNull;
import org.dozer.CustomConverter;
import javax.annotation.Nonnull;
/**
* Dozer converter implementation to convert data types to JSON format.
*
* @author amajumdar
*/
public class DozerJsonTypeConverter implements CustomConverter {
private TypeConverterFactory typeConverterFactory;
/**
* Constructor.
*
* @param typeConverterFactory Type converter factory
*/
public DozerJsonTypeConverter(@Nonnull @NonNull final TypeConverterFactory typeConverterFactory) {
this.typeConverterFactory = typeConverterFactory;
}
@Override
public Object convert(final Object existingDestinationFieldValue,
final Object sourceFieldValue,
final Class<?> destinationClass,
final Class<?> sourceClass) {
JsonNode result = null;
final Type type = (Type) sourceFieldValue;
final ConnectorTypeConverter typeConverter;
try {
typeConverter = this.typeConverterFactory.get(MetacatContextManager.getContext().getDataTypeContext());
} catch (final Exception e) {
throw new IllegalStateException("Unable to get a type converter", e);
}
try {
result = typeConverter.fromMetacatTypeToJson(type);
} catch (final Exception ignored) {
// TODO: Handle exception.
}
return result;
}
}
| 1,855 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/converter/ConverterUtil.java
|
/*
*
* Copyright 2017 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://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.server.converter;
import com.google.common.collect.Maps;
import com.netflix.metacat.common.MetacatRequestContext;
import com.netflix.metacat.common.dto.AuditDto;
import com.netflix.metacat.common.dto.CatalogDto;
import com.netflix.metacat.common.dto.ClusterDto;
import com.netflix.metacat.common.dto.DatabaseDto;
import com.netflix.metacat.common.dto.FieldDto;
import com.netflix.metacat.common.dto.GetPartitionsRequestDto;
import com.netflix.metacat.common.dto.ViewDto;
import com.netflix.metacat.common.dto.Pageable;
import com.netflix.metacat.common.dto.PartitionDto;
import com.netflix.metacat.common.dto.PartitionsSaveRequestDto;
import com.netflix.metacat.common.dto.PartitionsSaveResponseDto;
import com.netflix.metacat.common.dto.Sort;
import com.netflix.metacat.common.dto.StorageDto;
import com.netflix.metacat.common.dto.TableDto;
import com.netflix.metacat.common.server.connectors.ConnectorRequestContext;
import com.netflix.metacat.common.server.connectors.model.AuditInfo;
import com.netflix.metacat.common.server.connectors.model.CatalogInfo;
import com.netflix.metacat.common.server.connectors.model.ClusterInfo;
import com.netflix.metacat.common.server.connectors.model.DatabaseInfo;
import com.netflix.metacat.common.server.connectors.model.FieldInfo;
import com.netflix.metacat.common.server.connectors.model.ViewInfo;
import com.netflix.metacat.common.server.connectors.model.PartitionInfo;
import com.netflix.metacat.common.server.connectors.model.PartitionListRequest;
import com.netflix.metacat.common.server.connectors.model.PartitionsSaveRequest;
import com.netflix.metacat.common.server.connectors.model.PartitionsSaveResponse;
import com.netflix.metacat.common.server.connectors.model.StorageInfo;
import com.netflix.metacat.common.server.connectors.model.TableInfo;
import lombok.NonNull;
import org.dozer.CustomConverter;
import org.dozer.DozerBeanMapper;
import org.dozer.Mapper;
import org.dozer.loader.api.BeanMappingBuilder;
import org.dozer.loader.api.FieldsMappingOptions;
import org.dozer.loader.api.TypeMappingOptions;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Map;
/**
* Mapper from Dto to Connector Info.
*
* @author amajumdar
* @since 1.0.0
*/
public class ConverterUtil {
private static final String ID_TYPE_CONVERTER = "typeConverter";
private static final String ID_JSON_TYPE_CONVERTER = "jsonTypeConverter";
private final Mapper mapper;
/**
* Constructor.
*
* @param dozerTypeConverter custom dozer converter for types
* @param dozerJsonTypeConverter custom dozer converter for types to JSON format
*/
public ConverterUtil(@Nonnull @NonNull final DozerTypeConverter dozerTypeConverter,
@Nonnull @NonNull final DozerJsonTypeConverter dozerJsonTypeConverter) {
final DozerBeanMapper dozerBeanMapper = new DozerBeanMapper();
final BeanMappingBuilder builder = new BeanMappingBuilder() {
@Override
protected void configure() {
mapping(FieldDto.class, FieldInfo.class, TypeMappingOptions.oneWay())
.fields("type", "type", FieldsMappingOptions.customConverterId(ID_TYPE_CONVERTER))
.fields("partition_key", "partitionKey", FieldsMappingOptions.copyByReference())
.fields("source_type", "sourceType", FieldsMappingOptions.copyByReference());
mapping(FieldInfo.class, FieldDto.class, TypeMappingOptions.oneWay())
.fields("type", "type", FieldsMappingOptions.customConverterId(ID_TYPE_CONVERTER))
.fields("partitionKey", "partition_key", FieldsMappingOptions.copyByReference())
.fields("sourceType", "source_type", FieldsMappingOptions.copyByReference())
.fields("type", "jsonType", FieldsMappingOptions.customConverterId(ID_JSON_TYPE_CONVERTER));
mapping(TableDto.class, TableInfo.class)
.fields("name", "name", FieldsMappingOptions.copyByReference());
mapping(DatabaseDto.class, DatabaseInfo.class)
.fields("name", "name", FieldsMappingOptions.copyByReference());
mapping(PartitionDto.class, PartitionInfo.class)
.fields("name", "name", FieldsMappingOptions.copyByReference());
mapping(CatalogDto.class, CatalogInfo.class);
mapping(ClusterDto.class, ClusterInfo.class);
mapping(AuditDto.class, AuditInfo.class);
mapping(ViewDto.class, ViewInfo.class);
mapping(StorageDto.class, StorageInfo.class);
}
};
dozerBeanMapper.addMapping(builder);
final Map<String, CustomConverter> customConverterMap = Maps.newHashMap();
customConverterMap.put(ID_TYPE_CONVERTER, dozerTypeConverter);
customConverterMap.put(ID_JSON_TYPE_CONVERTER, dozerJsonTypeConverter);
dozerBeanMapper.setCustomConvertersWithId(customConverterMap);
this.mapper = dozerBeanMapper;
}
/**
* Converts from CatalogInfo to CatalogDto.
*
* @param catalogInfo connector catalog info
* @return catalog dto
*/
public CatalogDto toCatalogDto(final CatalogInfo catalogInfo) {
return this.mapper.map(catalogInfo, CatalogDto.class);
}
/**
* Converts from CatalogDto to CatalogInfo.
*
* @param catalogDto catalog dto
* @return connector catalog info
*/
public CatalogInfo fromCatalogDto(final CatalogDto catalogDto) {
return this.mapper.map(catalogDto, CatalogInfo.class);
}
/**
* Converts from ClusterInfo to ClusterDto.
*
* @param clusterInfo catalog cluster info
* @return cluster dto
*/
public ClusterDto toClusterDto(final ClusterInfo clusterInfo) {
return this.mapper.map(clusterInfo, ClusterDto.class);
}
/**
* Converts from ClusterDto to ClusterInfo.
*
* @param clusterDto catalog cluster dto
* @return cluster info
*/
public ClusterInfo fromClusterDto(final ClusterDto clusterDto) {
return this.mapper.map(clusterDto, ClusterInfo.class);
}
/**
* Converts from DatabaseInfo to DatabaseDto.
*
* @param databaseInfo connector table info
* @return database dto
*/
public DatabaseDto toDatabaseDto(final DatabaseInfo databaseInfo) {
return this.mapper.map(databaseInfo, DatabaseDto.class);
}
/**
* Converts from TableDto to TableInfo.
*
* @param databaseDto database dto
* @return connector database info
*/
public DatabaseInfo fromDatabaseDto(final DatabaseDto databaseDto) {
return this.mapper.map(databaseDto, DatabaseInfo.class);
}
/**
* Converts from TableInfo to TableDto.
*
* @param tableInfo connector table info
* @return table dto
*/
public TableDto toTableDto(final TableInfo tableInfo) {
final TableDto result = this.mapper.map(tableInfo, TableDto.class);
//TODO: Add this logic in the mapping
final List<FieldDto> fields = result.getFields();
if (fields != null) {
int index = 0;
for (final FieldDto field : fields) {
field.setPos(index++);
}
}
return result;
}
/**
* Converts from TableDto to TableInfo.
*
* @param tableDto table dto
* @return connector table info
*/
public TableInfo fromTableDto(final TableDto tableDto) {
return mapper.map(tableDto, TableInfo.class);
}
/**
* Converts from PartitionInfo to PartitionDto.
*
* @param partitionInfo connector partition info
* @return partition dto
*/
public PartitionDto toPartitionDto(final PartitionInfo partitionInfo) {
return mapper.map(partitionInfo, PartitionDto.class);
}
/**
* Converts from PartitionDto to PartitionInfo.
*
* @param partitionDto partition dto
* @return connector partition info
*/
public PartitionInfo fromPartitionDto(final PartitionDto partitionDto) {
return mapper.map(partitionDto, PartitionInfo.class);
}
/**
* Creates the connector context.
*
* @param metacatRequestContext request context
* @return connector context
*/
public ConnectorRequestContext toConnectorContext(final MetacatRequestContext metacatRequestContext) {
return mapper.map(metacatRequestContext, ConnectorRequestContext.class);
}
/**
* Creates the partition list connector request.
*
* @param partitionsRequestDto request containing the filter and other properties used for listing
* @param pageable pageable info
* @param sort sort info
* @return connector request
*/
public PartitionListRequest toPartitionListRequest(final GetPartitionsRequestDto partitionsRequestDto,
final Pageable pageable, final Sort sort) {
if (partitionsRequestDto != null) {
if (partitionsRequestDto.getIncludePartitionDetails() == null) {
partitionsRequestDto.setIncludePartitionDetails(false);
}
if (partitionsRequestDto.getIncludeAuditOnly() == null) {
partitionsRequestDto.setIncludeAuditOnly(false);
}
final PartitionListRequest result = mapper.map(partitionsRequestDto, PartitionListRequest.class);
result.setPageable(pageable);
result.setSort(sort);
return result;
} else {
return new PartitionListRequest(null, null, false, pageable, sort, false);
}
}
/**
* Creates the partition list connector request.
*
* @param partitionsRequestDto request containing the save request information
* @return connector request
*/
public PartitionsSaveRequest toPartitionsSaveRequest(final PartitionsSaveRequestDto partitionsRequestDto) {
return mapper.map(partitionsRequestDto, PartitionsSaveRequest.class);
}
/**
* Creates the partition list connector request.
*
* @param partitionsSaveResponse response on saving partitions
* @return response dto
*/
public PartitionsSaveResponseDto toPartitionsSaveResponseDto(final PartitionsSaveResponse partitionsSaveResponse) {
return mapper.map(partitionsSaveResponse, PartitionsSaveResponseDto.class);
}
}
| 1,856 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/converter/package-info.java
|
/*
*
* Copyright 2016 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://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.
*
*/
/**
* Converter classes.
*
* @author amajumdar
*/
package com.netflix.metacat.common.server.converter;
| 1,857 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/converter/DefaultTypeConverter.java
|
/*
*
* Copyright 2017 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://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.server.converter;
import com.netflix.metacat.common.server.connectors.ConnectorTypeConverter;
import com.netflix.metacat.common.type.Type;
import com.netflix.metacat.common.type.TypeRegistry;
import com.netflix.metacat.common.type.TypeSignature;
import lombok.NonNull;
import javax.annotation.Nonnull;
/**
* Default type converter. Converter for metacat type representations.
*
* @author amajumdar
* @since 1.0.0
*/
public class DefaultTypeConverter implements ConnectorTypeConverter {
/**
* {@inheritDoc}
*/
@Override
public Type toMetacatType(@Nonnull @NonNull final String type) {
final TypeSignature signature = TypeSignature.parseTypeSignature(type);
return TypeRegistry.getTypeRegistry().getType(signature);
}
/**
* {@inheritDoc}
*/
@Override
public String fromMetacatType(@Nonnull @NonNull final Type type) {
return type.getDisplayName();
}
}
| 1,858 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/util/DataSourceManager.java
|
/*
* Copyright 2016 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://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.server.util;
import com.google.common.collect.Maps;
import java.sql.SQLException;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.jdbc.pool.DataSourceFactory;
import org.apache.tomcat.jdbc.pool.DataSourceProxy;
import javax.annotation.PreDestroy;
import javax.management.ObjectName;
import javax.sql.DataSource;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
/**
* Data source manager.
*/
@Slf4j
public final class DataSourceManager {
private static final String JDO_PREFIX = "javax.jdo.option.";
private static DataSourceManager instance = new DataSourceManager();
private Map<String, DataSource> dataSources = Maps.newConcurrentMap();
private DataSourceManager() {
}
/**
* This method has been provided so that it can be used in the connectors. We could have injected into the plugins.
*
* @return DataSourceManager
*/
public static DataSourceManager get() {
return instance;
}
/**
* Initialize a data source and store it.
*
* @param name catalog name
* @param properties properties
* @return DataSourceManager
*/
public DataSourceManager load(final String name, final Map<String, String> properties) {
if (dataSources.get(name) == null) {
createDataSource(name, properties);
}
return this;
}
/**
* Initialize a data source and store it.
*
* @param catalogName catalog name
* @param properties properties
* @return DataSourceManager
*/
public DataSourceManager load(final String catalogName, final Properties properties) {
if (dataSources.get(catalogName) == null) {
createDataSource(catalogName, properties);
}
return this;
}
/**
* Returns the data source loaded for the given catalog.
*
* @param name catalog name
* @return DataSource
*/
public DataSource get(final String name) {
return dataSources.get(name);
}
/**
* Refresh the Connection Pool of the data source.
* @param name of the DataSource whose ConnectionPool has to be refreshed.
* @throws SQLException if pool cannot be re-created.
* @return true if success. false otherwise.
*/
public synchronized boolean refreshConnectionPool(final String name) throws SQLException {
final DataSource source = dataSources.get(name);
if (!(source instanceof DataSourceProxy)) {
return false;
}
final DataSourceProxy proxy = (DataSourceProxy) source;
proxy.close(true);
proxy.createPool();
return true;
}
private synchronized void createDataSource(final String name, final Map props) {
if (dataSources.get(name) == null) {
final Properties dataSourceProperties = new Properties();
props.forEach((key, value) -> {
final String prop = String.valueOf(key);
if (prop.startsWith(JDO_PREFIX)) {
dataSourceProperties.put(prop.substring(JDO_PREFIX.length()), value);
}
});
if (!dataSourceProperties.isEmpty()) {
try {
final DataSource dataSource = new DataSourceFactory().createDataSource(dataSourceProperties);
//
// Explicitly registering the datasource with the JMX server bean.
//
((org.apache.tomcat.jdbc.pool.DataSource) dataSource)
.preRegister(null, new ObjectName(String.format("jdbc.pool:name=%s", name)));
dataSources.put(name, dataSource);
} catch (Exception e) {
throw new RuntimeException(String
.format("Failed to load the data source for catalog %s with error [%s]", name,
e.getMessage()), e);
}
}
}
}
/**
* Closes all the data sources stored in the manager.
*/
@PreDestroy
public void close() {
final Iterator<DataSource> iter = dataSources.values().iterator();
while (iter.hasNext()) {
final DataSourceProxy dataSource = (DataSourceProxy) iter.next();
if (dataSource != null) {
dataSource.close();
}
iter.remove();
}
}
}
| 1,859 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/util/MetacatUtils.java
|
//CHECKSTYLE:OFF
package com.netflix.metacat.common.server.util;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.io.Files;
import com.netflix.metacat.common.dto.TableDto;
import com.netflix.metacat.common.server.connectors.ConnectorContext;
import com.netflix.metacat.common.server.properties.Config;
import com.netflix.metacat.common.server.spi.MetacatCatalogConfig;
import com.netflix.spectator.api.Registry;
import org.springframework.context.ApplicationContext;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FileInputStream;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
/**
* General metacat utility methods.
*/
public class MetacatUtils {
public static final String ICEBERG_MIGRATION_DO_NOT_MODIFY_TAG = "iceberg_migration_do_not_modify";
public static final String NAME_TAGS = "tags";
/**
* Iceberg common view field names.
*/
public static final String COMMON_VIEW = "common_view";
public static final String STORAGE_TABLE = "storage_table";
/**
* Default Ctor.
*/
private MetacatUtils() {
}
/**
* List files in a given dir.
*
* @param dir The directory.
* @return List of files if any.
*/
public static List<File> listFiles(final File dir) {
if (dir != null && dir.isDirectory()) {
final File[] files = dir.listFiles();
if (files != null) {
return ImmutableList.copyOf(files);
}
}
return ImmutableList.of();
}
/**
* Load properties from a file.
*
* @param file Properties file.
* @return A Map of properties.
* @throws Exception IOException on failure to load file.
*/
public static Map<String, String> loadProperties(final File file) throws Exception {
Preconditions.checkNotNull(file, "file is null");
final Properties properties = new Properties();
try (FileInputStream in = new FileInputStream(file)) {
properties.load(in);
}
return Maps.fromProperties(properties);
}
public static ConnectorContext buildConnectorContext(
final File file,
final String connectorType,
final Config config,
final Registry registry,
final ApplicationContext applicationContext,
final Map<String, String> properties) {
// Catalog shard name should be unique. Usually the catalog name is same as the catalog shard name.
// If multiple catalog property files refer the same catalog name, then there will be multiple shard names
// with the same catalog name.
final String catalogShardName = Files.getNameWithoutExtension(file.getName());
// If catalog name is not specified, then use the catalog shard name.
final String catalogName = properties.getOrDefault(MetacatCatalogConfig.Keys.CATALOG_NAME, catalogShardName);
return new ConnectorContext(catalogName, catalogShardName, connectorType, config, registry,
applicationContext, properties);
}
public static boolean configHasDoNotModifyForIcebergMigrationTag(final Set<String> tags) {
return Optional.ofNullable(tags).orElse(Collections.emptySet()).stream().
anyMatch(t -> t.trim().equalsIgnoreCase(ICEBERG_MIGRATION_DO_NOT_MODIFY_TAG));
}
public static boolean hasDoNotModifyForIcebergMigrationTag(@Nullable final TableDto tableDto,
final Set<String> tags) {
if (tableDto != null) {
final Set<String> tableTags = getTableTags(tableDto.getDefinitionMetadata());
if (tableTags != null) {
return configHasDoNotModifyForIcebergMigrationTag(tags) &&
tableTags.stream().anyMatch(t -> t.trim().equalsIgnoreCase(ICEBERG_MIGRATION_DO_NOT_MODIFY_TAG));
}
}
return false;
}
public static Set<String> getTableTags(@Nullable final ObjectNode definitionMetadata) {
final Set<String> tags = Sets.newHashSet();
if (definitionMetadata != null && definitionMetadata.get(NAME_TAGS) != null) {
final JsonNode tagsNode = definitionMetadata.get(NAME_TAGS);
if (tagsNode.isArray() && tagsNode.size() > 0) {
for (JsonNode tagNode : tagsNode) {
tags.add(tagNode.textValue().trim());
}
}
}
return tags;
}
public static String getIcebergMigrationExceptionMsg(final String requestType,
final String tableName) {
return String.format("%s to hive table: %s are temporarily blocked " +
"for automated migration to iceberg. Please retry",
requestType, tableName);
}
/**
* check if the table is a common view.
*
* @param tableMetadata table metadata map
* @return true for common view
*/
public static boolean isCommonView(final Map<String, String> tableMetadata) {
return tableMetadata != null && Boolean.parseBoolean(tableMetadata.get(COMMON_VIEW));
}
/**
* Returns the name of the common view storage table if present.
*
* @param tableMetadata the table metadata
* @return Storage table name.
*/
public static Optional<String> getCommonViewStorageTable(final Map<String, String> tableMetadata) {
if (tableMetadata != null) {
return Optional.ofNullable(tableMetadata.get(STORAGE_TABLE));
}
return Optional.empty();
}
}
| 1,860 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/util/MetacatContextManager.java
|
/*
*
* Copyright 2016 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://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.server.util;
import com.netflix.metacat.common.MetacatRequestContext;
/**
* Metacat context manager.
*/
public final class MetacatContextManager {
private static InheritableThreadLocal<MetacatRequestContext> context = new InheritableThreadLocal<>();
private MetacatContextManager() {
}
/**
* Removes the context from this manager.
*/
public static void removeContext() {
context.remove();
}
/**
* Returns the current thread context.
*
* @return context
*/
public static MetacatRequestContext getContext() {
MetacatRequestContext result = context.get();
if (result == null) {
result = new MetacatRequestContext();
setContext(result);
}
return result;
}
/**
* Sets the context in this manager.
*
* @param context context
*/
public static void setContext(final MetacatRequestContext context) {
MetacatContextManager.context.set(context);
}
}
| 1,861 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/util/RegistryUtil.java
|
/*
* Copyright 2017 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://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.server.util;
import com.netflix.spectator.api.Registry;
import java.util.concurrent.ThreadPoolExecutor;
/**
* Utility functions for Registry.
* @author amajumdar
*/
public final class RegistryUtil {
private static final String NAME_MONITORED_POOL = "MonitoredThreadPool_";
private RegistryUtil() { }
/**
* Register the pool properties.
* @param registry Spectator registry
* @param name name of the monitor
* @param pool thread pool
*/
public static void registerThreadPool(final Registry registry,
final String name,
final ThreadPoolExecutor pool) {
registry.gauge(NAME_MONITORED_POOL + name + "_" + "activeCount", pool, ThreadPoolExecutor::getActiveCount);
registry.gauge(NAME_MONITORED_POOL + name + "_" + "completedTaskCount", pool,
ThreadPoolExecutor::getCompletedTaskCount);
registry.gauge(NAME_MONITORED_POOL + name + "_" + "corePoolSize", pool, ThreadPoolExecutor::getCorePoolSize);
registry
.gauge(NAME_MONITORED_POOL + name + "_" + "maximumPoolSize", pool, ThreadPoolExecutor::getMaximumPoolSize);
registry.gauge(NAME_MONITORED_POOL + name + "_" + "poolSize", pool, ThreadPoolExecutor::getPoolSize);
registry.collectionSize(NAME_MONITORED_POOL + name + "_" + "queueSize", pool.getQueue());
registry.gauge(NAME_MONITORED_POOL + name + "_" + "taskCount", pool, ThreadPoolExecutor::getTaskCount);
}
}
| 1,862 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/util/ThreadServiceManager.java
|
/*
* Copyright 2016 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://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.server.util;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.netflix.metacat.common.server.properties.Config;
import com.netflix.spectator.api.Registry;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.PreDestroy;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* Thread service manager.
*
* @author amajumdar
*/
@Getter
@Slf4j
public class ThreadServiceManager {
private ListeningExecutorService executor;
/**
* Constructor.
*
* @param registry registry for spectator
* @param config Program configuration
*/
@Autowired
public ThreadServiceManager(final Registry registry, final Config config) {
final ExecutorService executorService = newFixedThreadPool(
config.getServiceMaxNumberOfThreads(),
config.getServiceMaxNumberOfThreads(),
"metacat-service-pool-%d",
1000
);
this.executor = MoreExecutors.listeningDecorator(executorService);
RegistryUtil.registerThreadPool(registry, "metacat-service-pool", (ThreadPoolExecutor) executorService);
}
/**
* Constructor.
*
* @param registry registry for spectator
* @param maxThreads maximum number of threads
* @param maxQueueSize maximum queue size
* @param usage an identifier where this pool is used
*/
public ThreadServiceManager(final Registry registry, final int maxThreads,
final int maxQueueSize, final String usage) {
final ExecutorService executorService = newFixedThreadPool(
2,
maxThreads,
"metacat-" + usage + "-pool-%d",
maxQueueSize
);
this.executor = MoreExecutors.listeningDecorator(executorService);
RegistryUtil.registerThreadPool(registry, "metacat-" + usage + "-pool",
(ThreadPoolExecutor) executorService);
}
/**
* Stops this manager.
*/
@PreDestroy
public void stop() {
if (this.executor != null) {
// Make the executor accept no new threads and finish all existing
// threads in the queue
this.executor.shutdown();
try {
this.executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
log.error("Error while shutting down executor service : ", e);
}
}
}
@SuppressWarnings("checkstyle:hiddenfield")
private ExecutorService newFixedThreadPool(
final int minThreads,
final int maxThreads,
final String threadFactoryName,
final int queueSize
) {
return new ThreadPoolExecutor(
minThreads,
maxThreads,
0L,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(queueSize),
new ThreadFactoryBuilder().setNameFormat(threadFactoryName).build(),
(r, executor) -> {
// this will block if the queue is full
try {
executor.getQueue().put(r);
} catch (InterruptedException e) {
throw Throwables.propagate(e);
}
}
);
}
}
| 1,863 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/util/PoolStatsInterceptor.java
|
/*
*
* Copyright 2016 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://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.server.util;
import com.netflix.metacat.common.server.monitoring.Metrics;
import com.netflix.spectator.api.Gauge;
import com.netflix.spectator.api.Registry;
import com.netflix.spectator.api.Spectator;
import org.apache.tomcat.jdbc.pool.ConnectionPool;
import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.apache.tomcat.jdbc.pool.PooledConnection;
import java.util.Map;
/**
* Pool stats interceptor.
*
* @author amajumdar
*/
public class PoolStatsInterceptor extends JdbcInterceptor {
/**
* Metric name.
*/
public static final String PROP_METRIC_NAME = "name";
private Gauge metricNameTotalGauage;
private Gauge metricNameActiveGauage;
private Gauge metricNameIdleGauage;
private final Registry registry = Spectator.globalRegistry();
/**
* Constructor.
*/
public PoolStatsInterceptor() {
super();
}
@Override
public void reset(final ConnectionPool parent, final PooledConnection con) {
publishMetric(parent);
}
@Override
public void disconnected(final ConnectionPool parent, final PooledConnection con, final boolean finalizing) {
publishMetric(parent);
}
private void publishMetric(final ConnectionPool parent) {
if (parent != null
&& metricNameTotalGauage != null
&& metricNameActiveGauage != null
&& metricNameIdleGauage != null) {
metricNameTotalGauage.set(parent.getSize());
metricNameActiveGauage.set(parent.getActive());
metricNameIdleGauage.set(parent.getIdle());
}
}
/**
* Sets the metric.
*
* @param metricName metric name
*/
public void setMetricName(final String metricName) {
metricNameIdleGauage = registry.gauge(
registry.createId(Metrics.GaugeConnectionsIdle + "." + metricName));
metricNameActiveGauage = registry.gauge(
registry.createId(Metrics.GaugeConnectionsActive + "." + metricName));
metricNameTotalGauage = registry.gauge(
registry.createId(Metrics.GaugeConnectionsTotal + "." + metricName));
}
@Override
public void setProperties(final Map<String, PoolProperties.InterceptorProperty> properties) {
super.setProperties(properties);
final PoolProperties.InterceptorProperty nameProperty = properties.get(PROP_METRIC_NAME);
if (nameProperty != null) {
setMetricName(nameProperty.getValue());
}
}
}
| 1,864 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/util/package-info.java
|
/*
*
* Copyright 2016 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://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.
*
*/
/**
* This package includes utility classes.
*
* @author amajumdar
*/
@ParametersAreNonnullByDefault
package com.netflix.metacat.common.server.util;
import javax.annotation.ParametersAreNonnullByDefault;
| 1,865 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/UserMetadataService.java
|
/*
*
* Copyright 2016 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://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.server.usermetadata;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.DefinitionMetadataDto;
import com.netflix.metacat.common.dto.HasDefinitionMetadata;
import com.netflix.metacat.common.dto.HasMetadata;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
/**
* User metadata service API.
*
* @author amajumdar,zhenl
*/
public interface UserMetadataService {
/**
* Config location.
*/
String METACAT_USERMETADATA_CONFIG_LOCATION = "metacat.usermetadata.config.location";
/**
* Datasource key.
*/
String NAME_DATASOURCE = "metacat-usermetadata";
/**
* Delete data metadata for the given uris.
*
* @param uris list of uris.
*/
default void deleteDataMetadata(List<String> uris) {
}
/**
* Delete the delete markers for data metadata for the given uris.
*
* @param uris list of uris.
*/
default void deleteDataMetadataDeletes(List<String> uris) {
}
/**
* Mark data metadatas for the given uris for deletion.
*
* @param userId user name
* @param uris list of uris
*/
default void softDeleteDataMetadata(String userId, List<String> uris) {
}
/**
* Delete definition metadatas for the given names.
*
* @param names list of names
*/
default void deleteDefinitionMetadata(List<QualifiedName> names) {
}
/**
* Delete definition metadata older than the given timestamp for names
* that match the given pattern.
*
* @param qualifiedNamePattern The pattern to match against qualified names.
* @param lastUpdated The lastUpdated timestamp to use as a cut-off.
*/
default void deleteStaleDefinitionMetadata(String qualifiedNamePattern, Date lastUpdated) {
}
/**
* Delete definition metadata and soft delete data metadata.
*
* @param userId username
* @param holders metadatas
*/
default void deleteMetadata(String userId, List<HasMetadata> holders) {
}
/**
* Returns data metadata for the given uri.
*
* @param uri uri.
* @return data metadata for the given uri.
*/
default Optional<ObjectNode> getDataMetadata(String uri) {
return Optional.empty();
}
/**
* Returns the map of uri to data metadata.
*
* @param uris list of uris.
* @return map of uri to data metadata.
*/
@Nonnull
default Map<String, ObjectNode> getDataMetadataMap(List<String> uris) {
return Collections.emptyMap();
}
/**
* Returns the definition metadata for the given name. This method is used for internal query without
* applying interceptor.
*
* @param name name
* @return definition metadata for the given name
*/
default Optional<ObjectNode> getDefinitionMetadata(QualifiedName name) {
return Optional.empty();
}
/**
* Returns the definition metadata for the given name after applying interceptor. This method should be used for
* all the calls return to outside. We assume that all the REST apis ( get, update, search, create) will return
* the same result of a table.
* @param name name
* @param getMetadataInterceptorParameters get Metadata Interceptor parameters
* @return definition metadata for the given name
*/
@Nonnull
default Optional<ObjectNode> getDefinitionMetadataWithInterceptor(
QualifiedName name,
GetMetadataInterceptorParameters getMetadataInterceptorParameters) {
return Optional.empty();
}
/**
* Returns the descendants for the given name.
*
* @param name name
* @return list of qualified names
*/
default List<QualifiedName> getDescendantDefinitionNames(QualifiedName name) {
return Collections.emptyList();
}
/**
* Returns the descendant uris.
*
* @param uri uri
* @return list of descendant uris.
*/
default List<String> getDescendantDataUris(String uri) {
return Collections.emptyList();
}
/**
* Returns a map of name to definition metadata. This is used for partitions only. We do not apply interceptor
* for partition level definition metadata.
*
* @param names list of names
* @return map of name to definition metadata
*/
@Nonnull
default Map<String, ObjectNode> getDefinitionMetadataMap(List<QualifiedName> names) {
return Collections.emptyMap();
}
/**
* Save data metadata.
*
* @param uri uri
* @param userId user name
* @param metadata metadata
* @param merge if true, will merge with existing metadata
*/
default void saveDataMetadata(
String uri,
String userId,
Optional<ObjectNode> metadata,
boolean merge
) {
}
/**
* Saves definition metadata with interceptor applied.
*
* @param name name
* @param userId username
* @param metadata metadata
* @param merge if true, will merge with existing metadata
*/
default void saveDefinitionMetadata(
QualifiedName name,
String userId,
Optional<ObjectNode> metadata,
boolean merge
) {
}
/**
* Save metadata.
*
* @param userId username
* @param holder metadata
* @param merge if true, will merge with existing metadata
*/
default void saveMetadata(String userId, HasMetadata holder, boolean merge) {
}
/**
* Populate the metadata.
*
* @param holder metadata
* @param disableInterceptor diable interceptor
*/
default void populateMetadata(HasMetadata holder, boolean disableInterceptor) {
}
/**
* Populate the metadata.
*
* @param holder metadata
* @param definitionMetadata definition metadata
* @param dataMetadata data metadata
*/
default void populateMetadata(HasMetadata holder,
ObjectNode definitionMetadata, @Nullable ObjectNode dataMetadata) {
}
/**
* Rename data metadata uri.
*
* @param oldUri old uri
* @param newUri new uri
* @return number of records updated
*/
default int renameDataMetadataKey(String oldUri, String newUri) {
return 0;
}
/**
* Rename definition metadata name.
*
* @param oldName old name
* @param newName new name
* @return number of records updated
*/
default int renameDefinitionMetadataKey(QualifiedName oldName, QualifiedName newName) {
return 0;
}
/**
* Stop the user metadata service.
*
* @throws Exception error
*/
default void stop() throws Exception {
}
/**
* Saves metadata.
*
* @param user username
* @param holders metadatas
* @param merge if true, will merge with existing metadata
*/
default void saveMetadata(String user, List<? extends HasMetadata> holders, boolean merge) {
}
/**
* Return the list of definition metadata for the given property names.
*
* @param propertyNames names
* @param type type
* @param name name
* @param holder dto
* @param sortBy sort column
* @param sortOrder sort order
* @param offset offset
* @param limit size of the list
* @return list of definition metadata
*/
default List<DefinitionMetadataDto> searchDefinitionMetadata(
@Nullable Set<String> propertyNames,
@Nullable String type,
@Nullable String name,
@Nullable HasMetadata holder,
@Nullable String sortBy,
@Nullable String sortOrder,
@Nullable Integer offset,
@Nullable Integer limit
) {
return Collections.emptyList();
}
/**
* List the names for the given owners.
*
* @param owners list of owner names.
* @return list of qualified names
*/
default List<QualifiedName> searchByOwners(Set<String> owners) {
return Collections.emptyList();
}
/**
* List of uris marked for deletion.
*
* @param deletedPriorTo date
* @param offset offset
* @param limit size of the list
* @return list of uris.
*/
default List<String> getDeletedDataMetadataUris(Date deletedPriorTo, Integer offset, Integer limit) {
return Collections.emptyList();
}
/**
* Populate the owner in definitionMetadata, if missing, with the provider owner.
*
* @param holder definition metadata holder
* @param owner owner name.
*/
default void populateOwnerIfMissing(HasDefinitionMetadata holder, String owner) {
}
}
| 1,866 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/AuthorizationService.java
|
/*
* 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://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.server.usermetadata;
import com.netflix.metacat.common.QualifiedName;
/**
* Authorization Service API.
*
* @author zhenl
* @since 1.2.0
*/
public interface AuthorizationService {
/**
* Check metacat acl property if this operation is permitted.
*
* @param userName username
* @param name qualified Name
* @param op operation
*/
default void checkPermission(final String userName,
final QualifiedName name,
final MetacatOperation op) {
}
}
| 1,867 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/DefaultTagService.java
|
/*
* Copyright 2017 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://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.server.usermetadata;
/**
* Default Tag Service.
*
* @author zhenl
* @since 1.1.0
*/
public class DefaultTagService implements TagService {
}
| 1,868 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/BaseUserMetadataService.java
|
/*
*
* Copyright 2016 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://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.server.usermetadata;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.netflix.metacat.common.dto.HasDataMetadata;
import com.netflix.metacat.common.dto.HasDefinitionMetadata;
import com.netflix.metacat.common.dto.HasMetadata;
import java.util.Optional;
/**
* Base class for UserMetadataService.
*
* @author amajumdar
*/
public abstract class BaseUserMetadataService implements UserMetadataService {
/**
* Saves user metadata.
*
* @param userId user name
* @param holder metadata
* @param merge true if the metadata should be merged with existing metadata
*/
@Override
public void saveMetadata(final String userId, final HasMetadata holder, final boolean merge) {
if (holder instanceof HasDefinitionMetadata) {
final HasDefinitionMetadata defDto = (HasDefinitionMetadata) holder;
// If the user is updating the definition metadata do a merge on the existing metadata
final ObjectNode newMetadata = defDto.getDefinitionMetadata();
if (newMetadata != null) {
saveDefinitionMetadata(defDto.getDefinitionName(), userId, Optional.of(newMetadata), merge);
}
}
if (holder instanceof HasDataMetadata) {
final HasDataMetadata dataDto = (HasDataMetadata) holder;
// If the user is updating the data metadata and a separate data location exists,
// do a merge on the existing metadata
final ObjectNode newMetadata = dataDto.getDataMetadata();
if (newMetadata != null && dataDto.isDataExternal()) {
saveDataMetadata(dataDto.getDataUri(), userId, Optional.of(newMetadata), merge);
}
}
}
/**
* Populate the given metadata.
*
* @param holder metadata
*/
@Override
public void populateMetadata(final HasMetadata holder, final boolean disableIntercetpor) {
Optional<ObjectNode> metadata = Optional.empty();
if (holder instanceof HasDataMetadata) {
final HasDataMetadata dataDto = (HasDataMetadata) holder;
if (dataDto.isDataExternal()) {
metadata = getDataMetadata(dataDto.getDataUri());
}
}
Optional<ObjectNode> definitionMetadata = Optional.empty();
if (holder instanceof HasDefinitionMetadata) {
final HasDefinitionMetadata definitionDto = (HasDefinitionMetadata) holder;
definitionMetadata = disableIntercetpor ? this.getDefinitionMetadata(definitionDto.getDefinitionName())
: this.getDefinitionMetadataWithInterceptor(definitionDto.getDefinitionName(),
GetMetadataInterceptorParameters.builder().hasMetadata(holder).build());
}
populateMetadata(holder, definitionMetadata.orElse(null), metadata.orElse(null));
}
/**
* Populate metadata.
*
* @param holder metadata
* @param definitionMetadata definition metadata
* @param dataMetadata data metadata
*/
@Override
public void populateMetadata(
final HasMetadata holder,
final ObjectNode definitionMetadata,
final ObjectNode dataMetadata
) {
if (holder instanceof HasDefinitionMetadata) {
final HasDefinitionMetadata defDto = (HasDefinitionMetadata) holder;
defDto.setDefinitionMetadata(definitionMetadata);
}
if (holder instanceof HasDataMetadata) {
final HasDataMetadata dataDto = (HasDataMetadata) holder;
//data Metadata can be populated from iceberg metrics directly
if (dataDto.isDataExternal() || dataMetadata != null) {
dataDto.setDataMetadata(dataMetadata);
}
}
}
}
| 1,869 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/TagService.java
|
/*
*
* Copyright 2016 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://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.server.usermetadata;
import com.netflix.metacat.common.QualifiedName;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
* Tag Service API.
*
* @author amajumdar
* @author zhenl
*/
public interface TagService {
/**
* Returns the list of tags.
*
* @return list of tag names
*/
default Set<String> getTags() {
return Collections.emptySet();
}
/**
* Returns the list of <code>QualifiedName</code> of items that are tagged by the given <code>includeTags</code> and
* do not contain the given <code>excludeTags</code>.
*
* @param includeTags include items that contain tags
* @param excludeTags include items that do not contain tags
* @param sourceName catalog/source name
* @param databaseName database name
* @param tableName table name
* @param type metacat qualified name type
* @return list of qualified names of the items
*/
default List<QualifiedName> list(
@Nullable final Set<String> includeTags,
@Nullable final Set<String> excludeTags,
@Nullable final String sourceName,
@Nullable final String databaseName,
@Nullable final String tableName,
@Nullable final QualifiedName.Type type
) {
return Collections.emptyList();
}
/**
* Returns the list of <code>QualifiedName</code> of items that have tags containing the given tag text.
*
* @param tag partial text of a tag
* @param sourceName source/catalog name
* @param databaseName database name
* @param tableName table name
* @return list of qualified names of the items
*/
default List<QualifiedName> search(
@Nullable final String tag,
@Nullable final String sourceName,
@Nullable final String databaseName,
@Nullable final String tableName
) {
return Collections.emptyList();
}
/**
* Tags the given table with the given <code>tags</code>.
*
* @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 resource
*/
default Set<String> setTags(
final QualifiedName qualifiedName,
final Set<String> tags,
final boolean updateUserMetadata
) {
return Collections.emptySet();
}
/**
* Removes the tags from the given qualified name.
*
* @param qualifiedName table name
* @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 removeTags(
final QualifiedName qualifiedName,
final Boolean deleteAll,
@Nullable final Set<String> tags,
final boolean updateUserMetadata
) {
}
/**
* Delete the tag item along with its associated tags.
*
* @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 renameTableTags(final QualifiedName name, final String newTableName) {
}
}
| 1,870 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/MetacatOperation.java
|
/*
* 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://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.server.usermetadata;
import lombok.Getter;
/**
* Metacat Operation.
*
* @author zhenl
* @since 1.2.0
*/
@Getter
public enum MetacatOperation {
/**
* create operation.
*/
CREATE,
/**
* delete operation.
*/
DELETE,
/**
* rename operation.
*/
RENAME
}
| 1,871 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/UserMetadataServiceException.java
|
/*
*
* Copyright 2016 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://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.server.usermetadata;
/**
* User metadata service exception.
*/
public class UserMetadataServiceException extends RuntimeException {
/**
* Constructor.
*
* @param m message
* @param e exception
*/
public UserMetadataServiceException(final String m, final Exception e) {
super(m, e);
}
}
| 1,872 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/MetadataInterceptorImpl.java
|
/*
* 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://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.server.usermetadata;
/**
* Default Metadata Interceptor Impl.
* @author zhenl
* @since 1.2.0
*/
public class MetadataInterceptorImpl implements MetadataInterceptor {
}
| 1,873 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/AliasService.java
|
/*
* Copyright 2019 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://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.server.usermetadata;
import com.netflix.metacat.common.QualifiedName;
import lombok.NonNull;
/**
* Alias Service API.
*
* @author rveeramacheneni
* @since 1.3.0
*/
public interface AliasService {
/**
* Returns the original table name if present.
*
* @param tableAlias the table alias.
* @return the original name if present or the alias otherwise.
*/
default QualifiedName getTableName(@NonNull final QualifiedName tableAlias) {
return tableAlias;
}
}
| 1,874 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/GetMetadataInterceptorParameters.java
|
/*
* 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://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.server.usermetadata;
import com.netflix.metacat.common.dto.HasMetadata;
import lombok.Builder;
import java.util.Optional;
/**
* Get definition metadata parameters.
*
* @author zhenl
* @since 1.2.0
*/
@Builder
public class GetMetadataInterceptorParameters {
private HasMetadata hasMetadata;
public Optional<HasMetadata> getHasMetadata() {
return Optional.ofNullable(hasMetadata);
}
}
| 1,875 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/DefaultLookupService.java
|
/*
* Copyright 2017 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://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.server.usermetadata;
/**
* Default Look up Service.
*
* @author zhenl
* @since 1.1.0
*/
public class DefaultLookupService implements LookupService {
}
| 1,876 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/DefaultUserMetadataService.java
|
/*
* Copyright 2017 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://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.server.usermetadata;
/**
* Default User Metadata Service.
*
* @author zhenl
* @since 1.1.0
*/
public class DefaultUserMetadataService implements UserMetadataService {
}
| 1,877 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/LookupService.java
|
/*
*
* Copyright 2016 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://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.server.usermetadata;
import com.netflix.metacat.common.server.model.Lookup;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Set;
/**
* Lookup service API.
*
* @author amajumdar
*/
public interface LookupService {
/**
* Returns the lookup for the given <code>name</code>.
*
* @param name lookup name
* @return lookup
*/
@Nullable
default Lookup get(final String name) {
return null;
}
/**
* Returns the value of the lookup name.
*
* @param name lookup name
* @return scalar lookup value
*/
default String getValue(final String name) {
return null;
}
/**
* Returns the list of values of the lookup name.
*
* @param name lookup name
* @return list of lookup values
*/
default Set<String> getValues(final String name) {
return Collections.emptySet();
}
/**
* Returns the list of values of the lookup name.
*
* @param lookupId lookup id
* @return list of lookup values
*/
default Set<String> getValues(final Long lookupId) {
return Collections.emptySet();
}
/**
* Saves the lookup value.
*
* @param name lookup name
* @param values multiple values
* @return updated lookup
*/
@Nullable
default Lookup setValues(final String name, final Set<String> values) {
return null;
}
/**
* Saves the lookup value.
*
* @param name lookup name
* @param values multiple values
* @return updated lookup
*/
@Nullable
default Lookup addValues(final String name, final Set<String> values) {
return null;
}
/**
* Saves the lookup value.
*
* @param name lookup name
* @param value lookup value
* @return updated lookup
*/
@Nullable
default Lookup setValue(final String name, final String value) {
return null;
}
}
| 1,878 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/DefaultAliasService.java
|
/*
* Copyright 2019 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://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.server.usermetadata;
/**
* Alias Service API.
*
* @author rveeramacheneni
* @since 1.3.0
*/
public class DefaultAliasService implements AliasService {
}
| 1,879 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/MetadataInterceptor.java
|
/*
* 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://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.server.usermetadata;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.server.connectors.exception.InvalidMetadataException;
import javax.annotation.Nullable;
/**
* Business Metadata Manager.
*
* @author zhenl
* @since 1.2.0
*/
public interface MetadataInterceptor {
/**
* apply business rules before retrieving back. These rules may change or overriding existing
* business metadata.
*
* @param userMetadataService user metadata service
* @param name qualified name
* @param objectNode input metadata object node
* @param getMetadataInterceptorParameters get Metadata Interceptor Parameters
*/
default void onRead(final UserMetadataService userMetadataService,
final QualifiedName name, @Nullable final ObjectNode objectNode,
final GetMetadataInterceptorParameters getMetadataInterceptorParameters) {
}
/**
* Valide ObjectNode before storing it.
* @param userMetadataService user metadata service
* @param name qualified name
* @param objectNode input metadata object node
* @throws InvalidMetadataException business validation exception
*/
default void onWrite(final UserMetadataService userMetadataService,
final QualifiedName name, final ObjectNode objectNode)
throws InvalidMetadataException {
}
}
| 1,880 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/DefaultAuthorizationService.java
|
/*
* 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://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.server.usermetadata;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.exception.MetacatUnAuthorizedException;
import com.netflix.metacat.common.server.properties.Config;
import java.util.Map;
import java.util.Set;
/**
* Config based authorization service implementation.
*
* @author zhenl
* @since 1.2.0
*/
public class DefaultAuthorizationService implements AuthorizationService {
private final Config config;
/**
* Constructor.
*
* @param config metacat config
*/
public DefaultAuthorizationService(
final Config config
) {
this.config = config;
}
/**
* {@inheritDoc}
*/
@Override
public void checkPermission(final String userName,
final QualifiedName name,
final MetacatOperation op) {
if (config.isAuthorizationEnabled()) {
switch (op) {
case CREATE:
checkPermit(config.getMetacatCreateAcl(), userName, name, op);
break;
case RENAME:
case DELETE:
checkPermit(config.getMetacatDeleteAcl(), userName, name, op);
break;
default:
}
}
}
/**
* Check at database level.
*/
private void checkPermit(final Map<QualifiedName, Set<String>> accessACL,
final String userName,
final QualifiedName name,
final MetacatOperation op) {
final Set<String> users =
accessACL.get(QualifiedName.ofDatabase(name.getCatalogName(), name.getDatabaseName()));
if ((users != null) && !users.isEmpty() && !users.contains(userName)) {
throw new MetacatUnAuthorizedException(String.format("%s is not permitted for %s %s",
userName, op.name(), name
));
}
}
}
| 1,881 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/package-info.java
|
/*
*
* Copyright 2016 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://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.
*
*/
/**
* Common classes used in user metadata service.
*
* @author amajumdar
*/
@ParametersAreNonnullByDefault
package com.netflix.metacat.common.server.usermetadata;
import javax.annotation.ParametersAreNonnullByDefault;
| 1,882 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/spi/MetacatCatalogConfig.java
|
/*
* Copyright 2016 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://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.server.spi;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.server.connectors.model.CatalogInfo;
import com.netflix.metacat.common.server.connectors.model.ClusterInfo;
import lombok.Getter;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* Catalog config.
*/
@Getter
public final class MetacatCatalogConfig {
private static final Splitter COMMA_LIST_SPLITTER = Splitter.on(',').trimResults().omitEmptyStrings();
private final boolean includeViewsWithTables;
private final List<String> schemaBlacklist;
private final List<String> schemaWhitelist;
private final int thriftPort;
private final String type;
private final String catalogName;
private final ClusterInfo clusterInfo;
private boolean cacheEnabled;
private boolean interceptorEnabled;
private boolean hasDataExternal;
private MetacatCatalogConfig(
final String type,
final String catalogName,
final ClusterInfo clusterInfo,
final boolean includeViewsWithTables,
final List<String> schemaWhitelist,
final List<String> schemaBlacklist,
final int thriftPort,
final boolean cacheEnabled,
final boolean interceptorEnabled,
final boolean hasDataExternal) {
this.type = type;
this.catalogName = catalogName;
this.clusterInfo = clusterInfo;
this.includeViewsWithTables = includeViewsWithTables;
this.schemaBlacklist = schemaBlacklist;
this.schemaWhitelist = schemaWhitelist;
this.thriftPort = thriftPort;
this.cacheEnabled = cacheEnabled;
this.interceptorEnabled = interceptorEnabled;
this.hasDataExternal = hasDataExternal;
}
/**
* Creates the config.
*
* @param type type
* @param catalogName catalog name
* @param properties properties
* @return config
*/
public static MetacatCatalogConfig createFromMapAndRemoveProperties(
final String type,
final String catalogName,
final Map<String, String> properties) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(type), "type is required");
final String catalogType =
properties.containsKey(Keys.CATALOG_TYPE) ? properties.remove(Keys.CATALOG_TYPE) : type;
final List<String> schemaWhitelist = properties.containsKey(Keys.SCHEMA_WHITELIST)
? COMMA_LIST_SPLITTER.splitToList(properties.remove(Keys.SCHEMA_WHITELIST))
: Collections.EMPTY_LIST;
final List<String> schemaBlacklist = properties.containsKey(Keys.SCHEMA_BLACKLIST)
? COMMA_LIST_SPLITTER.splitToList(properties.remove(Keys.SCHEMA_BLACKLIST))
: Collections.EMPTY_LIST;
final boolean includeViewsWithTables = Boolean.parseBoolean(properties.remove(Keys.INCLUDE_VIEWS_WITH_TABLES));
int thriftPort = 0;
if (properties.containsKey(Keys.THRIFT_PORT)) {
thriftPort = Integer.parseInt(properties.remove(Keys.THRIFT_PORT));
}
// Cache properties
final boolean cacheEnabled =
Boolean.parseBoolean(properties.getOrDefault(Keys.CATALOG_CACHE_ENABLED, "false"));
// Interceptor properties
final boolean interceptorEnabled =
Boolean.parseBoolean(properties.getOrDefault(Keys.CATALOG_INTERCEPTOR_ENABLED, "true"));
// Has data external
final boolean hasDataExternal =
Boolean.parseBoolean(properties.getOrDefault(Keys.CATALOG_HAS_DATA_EXTERNAL, "false"));
// Cluster information
final String clusterName = properties.get(Keys.CLUSTER_NAME);
final String clusterAccount = properties.get(Keys.CLUSTER_ACCOUNT);
final String clusterAccountId = properties.get(Keys.CLUSTER_ACCOUNT_ID);
final String clusterEnv = properties.get(Keys.CLUSTER_ENV);
final String clusterRegion = properties.get(Keys.CLUSTER_REGION);
final ClusterInfo clusterInfo =
new ClusterInfo(clusterName, type, clusterAccount, clusterAccountId, clusterEnv, clusterRegion);
return new MetacatCatalogConfig(catalogType, catalogName, clusterInfo, includeViewsWithTables, schemaWhitelist,
schemaBlacklist, thriftPort, cacheEnabled, interceptorEnabled, hasDataExternal);
}
public boolean isThriftInterfaceRequested() {
return thriftPort != 0;
}
/**
* Returns true if catalog is a proxy one.
* @return Returns true if catalog is a proxy one.
*/
public boolean isProxy() {
return type.equalsIgnoreCase("proxy");
}
/**
* Creates the catalog info.
* @return catalog info
*/
public CatalogInfo toCatalogInfo() {
return CatalogInfo.builder().name(QualifiedName.ofCatalog(catalogName)).clusterInfo(clusterInfo).build();
}
/**
* Properties in the catalog.
*/
public static class Keys {
/**
* Catalog name. Usually catalog name is derived from the name of the catalog properties file.
* One could also specify it in the properties under the property name <code>catalog.name</code>.
* For example, if a catalog has two shards with catalog defined in two property files,
* then we can have the <code>catalog.name</code> set to one name.
*/
public static final String CATALOG_NAME = "catalog.name";
/**
* Connector type.
*/
public static final String CONNECTOR_NAME = "connector.name";
/**
* Catalog type.
*/
public static final String CATALOG_TYPE = "metacat.type";
/**
* True, if catalog cache is enabled.
*/
public static final String CATALOG_CACHE_ENABLED = "metacat.cache.enabled";
/**
* True, if catalog interceptor needs to be enabled.
*/
public static final String CATALOG_INTERCEPTOR_ENABLED = "metacat.interceptor.enabled";
/**
* True, if catalog stores data externally. Ex: Hive.
*/
public static final String CATALOG_HAS_DATA_EXTERNAL = "metacat.has-data-external";
/**
* List views with tables.
*/
public static final String INCLUDE_VIEWS_WITH_TABLES = "metacat.schema.list-views-with-tables";
/**
* Schemas that are black listed.
*/
public static final String SCHEMA_BLACKLIST = "metacat.schema.blacklist";
/**
* Schemas that are white listed.
*/
public static final String SCHEMA_WHITELIST = "metacat.schema.whitelist";
/**
* Thrift port.
*/
public static final String THRIFT_PORT = "metacat.thrift.port";
/**
* Cluster name.
*/
public static final String CLUSTER_NAME = "metacat.cluster.name";
/**
* Cluster account.
*/
public static final String CLUSTER_ACCOUNT = "metacat.cluster.account";
/**
* Cluster account id.
*/
public static final String CLUSTER_ACCOUNT_ID = "metacat.cluster.account-id";
/**
* Cluster region.
*/
public static final String CLUSTER_REGION = "metacat.cluster.region";
/**
* Cluster environment.
*/
public static final String CLUSTER_ENV = "metacat.cluster.env";
}
}
| 1,883 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/spi/package-info.java
|
/*
* Copyright 2017 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://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.
*/
/**
* This package includes spi config.
*
* @author amajumdar
*/
@ParametersAreNonnullByDefault
package com.netflix.metacat.common.server.spi;
import javax.annotation.ParametersAreNonnullByDefault;
| 1,884 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/Definition.java
|
/*
*
* 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://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.server.properties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.netflix.metacat.common.QualifiedName;
import lombok.NonNull;
import java.util.Set;
/**
* Definition metadata related properties.
*
* @author amajumdar
* @since 1.2.0
*/
@lombok.Data
public class Definition {
@NonNull
private Metadata metadata = new Metadata();
/**
* Metadata related properties.
*
* @author amajumdar
* @since 1.2.0
*/
@lombok.Data
public static class Metadata {
@NonNull
private Delete delete = new Delete();
private boolean disablePartitionDefinitionMetadata;
/**
* Delete related properties.
*
* @author amajumdar
* @since 1.2.0
*/
@lombok.Data
public static class Delete {
private boolean enableForTable = true;
private String enableDeleteForQualifiedNames;
private Set<QualifiedName> enableDeleteForQualifiedNamesSet;
/**
* Get the names stored in the variable as a List of fully qualified names.
*
* @return The names as a list or empty list if {@code enableDeleteForQualifiedNames} is null or empty
*/
@JsonIgnore
public Set<QualifiedName> getQualifiedNamesEnabledForDelete() {
if (enableDeleteForQualifiedNamesSet == null) {
enableDeleteForQualifiedNamesSet =
PropertyUtils.delimitedStringsToQualifiedNamesSet(this.enableDeleteForQualifiedNames, ',');
}
return enableDeleteForQualifiedNamesSet;
}
}
}
}
| 1,885 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/NotificationsProperties.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.Data;
import lombok.NonNull;
/**
* Properties related to notifications.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public class NotificationsProperties {
@NonNull
private Sns sns = new Sns();
/**
* SNS Properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Sns {
private boolean enabled; // false is default in Java no need to initialize
private int threadCount = 50;
private Topic topic = new Topic();
private AttachPartitionIds attachPartitionIds = new AttachPartitionIds();
/**
* SNS Topic settings.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Topic {
@NonNull
private Table table = new Table();
@NonNull
private Partition partition = new Partition();
/**
* Table notification settings.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Table {
private String arn; // Default to null
private String fallbackArn; // Default to null
}
/**
* Partition notification settings.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Partition {
private String arn; // Default to null
private String fallbackArn; // Default to null
private boolean enabled = true;
}
}
/**
* SNS Table PartitionUpdate payload setting.
*
* @author zhenl
* @since 1.2.1
*/
@Data
public static class AttachPartitionIds {
private boolean enabled = true; //default to true
private int maxPartitionIdNumber = 200;
}
}
}
| 1,886 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/HiveProperties.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.Data;
import lombok.NonNull;
/**
* Hive related properties for Metacat.
*
* @author tgianos
* @since 1.0.0
*/
@Data
//TODO: This shouldn't be in the common module. This should be in the Hive connector
public class HiveProperties {
@NonNull
private Metastore metastore = new Metastore();
@NonNull
private Iceberg iceberg = new Iceberg();
@NonNull
private CommonView commonview = new CommonView();
/**
* Metastore related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Metastore {
@NonNull
private Partition partition = new Partition();
private int fetchSize = 2500;
private int batchSize = 2500;
/**
* Metastore partition related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Partition {
@NonNull
private Name name = new Name();
private boolean escapeNameOnFilter = true;
/**
* Metastore partition name related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Name {
@NonNull
private Whitelist whitelist = new Whitelist();
/**
* Metastore partition name whitelist related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Whitelist {
@NonNull
private String pattern = "";
}
}
}
}
/**
* Iceberg related properties.
*
* @author zhenl
* @since 1.2.0
*/
@Data
public static class Iceberg {
@NonNull
private IcebergCacheProperties cache = new IcebergCacheProperties();
private boolean enabled;
private int fetchSizeInTableSummary = 100;
/* each retry needs a s3 access, default to 0 as no retry */
private int refreshFromMetadataLocationRetryNumber;
/* loading metadata consumes memory, cap to 500m as default */
private long maxMetadataFileSizeBytes = 500 * 1024 * 1024; //500m
/*iceberg://<db-name.table-name>/<partition>/snapshot_time=<dateCreated> */
private String partitionUriScheme = "iceberg";
private boolean isIcebergPreviousMetadataLocationCheckEnabled = true;
private boolean isShouldFetchOnlyMetadataLocationEnabled = true;
}
/**
* Iceberg cache related properties.
*
* @author amajumdar
* @since 1.3.0
*/
@Data
public static class IcebergCacheProperties {
private boolean enabled;
@NonNull
private TableMetadata metadata = new TableMetadata();
}
/**
* TableMetadata properties.
*
* @author amajumdar
*/
@Data
public static class TableMetadata {
private boolean enabled;
}
/**
* CommonView related properties.
*
* @author zhenl
* @since 1.3.0
*/
@Data
public static class CommonView {
private boolean enabled;
private boolean deleteStorageTable;
}
}
| 1,887 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/RateLimiterProperties.java
|
package com.netflix.metacat.common.server.properties;
import lombok.Data;
/**
* RateLimiter service properties.
*
* @author rveeramacheneni
*/
@Data
public class RateLimiterProperties {
private boolean enabled;
private boolean enforced;
}
| 1,888 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/PluginProperties.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.Data;
import lombok.NonNull;
/**
* Plugin related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public class PluginProperties {
@NonNull
private Config config = new Config();
/**
* Plugin config related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Config {
private String location;
}
}
| 1,889 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/ElasticsearchProperties.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.netflix.metacat.common.QualifiedName;
import lombok.Data;
import lombok.NonNull;
import java.util.List;
/**
* Properties related to Elasticsearch configuration.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public class ElasticsearchProperties {
private boolean enabled;
private long timeout = 30;
private long bulkTimeout = 120;
@NonNull
private Index index = new Index();
@NonNull
private MergeIndex mergeIndex = new MergeIndex();
@NonNull
private Cluster cluster = new Cluster();
@NonNull
private Refresh refresh = new Refresh();
@NonNull
private Scroll scroll = new Scroll();
@NonNull
private Publish publish = new Publish();
/**
* Elasticsearch index related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Index {
private String name = "metacat";
}
/**
* Elasticsearch merge index related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class MergeIndex {
private String name;
}
/**
* Elasticsearch cluster related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Cluster {
private String name;
private String nodes;
private int port = 7102;
@NonNull
private Discovery discovery = new Discovery();
/**
* Whether to use discovery or the lookup service to find Elasticsearch nodes.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Discovery {
private boolean useLookup;
}
}
/**
* Elasticsearch refresh related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Refresh {
@NonNull
private Include include = new Include();
@NonNull
private Exclude exclude = new Exclude();
@NonNull
private Partitions partitions = new Partitions();
@NonNull
private Threshold threshold = new Threshold();
/**
* Elasticsearch refresh inclusion related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Include {
private String catalogs;
private String databases;
private List<QualifiedName> databasesList;
/**
* Get the databases stored in the variable as a List of fully qualified names.
*
* @return The databases as a list or empty list if {@code names} is null or empty
*/
@JsonIgnore
public List<QualifiedName> getDatabasesAsListOfQualfiedNames() {
if (databasesList == null) {
databasesList = this.databases == null
? Lists.newArrayList()
: PropertyUtils.delimitedStringsToQualifiedNamesList(this.databases, ',');
}
return databasesList;
}
}
/**
* Elasticsearch refresh exclusion related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Exclude {
@NonNull
private Qualified qualified = new Qualified();
/**
* Elasticsearch refresh exclusion qualified related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Qualified {
private String names;
private List<QualifiedName> namesList;
/**
* Get the names stored in the variable as a List of fully qualified names.
*
* @return The names as a list or empty list if {@code names} is null or empty
*/
@JsonIgnore
public List<QualifiedName> getNamesAsListOfQualifiedNames() {
if (namesList == null) {
namesList = this.names == null
? Lists.newArrayList()
: PropertyUtils.delimitedStringsToQualifiedNamesList(this.names, ',');
}
return namesList;
}
}
}
/**
* Elasticsearch refresh partition related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Partitions {
@NonNull
private Include include = new Include();
/**
* Elasticsearch refresh partitions inclusion related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Include {
private String catalogs = "prodhive,testhive,s3,aegisthus";
}
}
/**
* Elasticsearch refresh threshold related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Threshold {
@NonNull
private Unmarked unmarked = new Unmarked();
/**
* Elasticsearch refresh threshold unmarked related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Unmarked {
@NonNull
private Databases databases = new Databases();
@NonNull
private Tables tables = new Tables();
/**
* Elasticsearch refresh threshold unmarked databases related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Databases {
private int delete = 100;
}
/**
* Elasticsearch refresh threshold unmarked tables related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Tables {
private int delete = 1000;
}
}
}
}
/**
* Elasticsearch scroll related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Scroll {
@NonNull
private Fetch fetch = new Fetch();
@NonNull
private Timeout timeout = new Timeout();
/**
* Elasticsearch scroll fetch related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Fetch {
private int size = 50000;
}
/**
* Elasticsearch scroll timeout related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Timeout {
private int ms = 600000;
}
}
/**
* Elasticsearch publish properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Publish {
private boolean partitionEnabled;
private boolean updateTablesWithSameUriEnabled;
private boolean metacatLogEnabled;
}
}
| 1,890 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/TypeProperties.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.Data;
/**
* Properties related to canonical types in Metacat.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public class TypeProperties {
private String converter = "com.netflix.metacat.common.server.converter.DefaultTypeConverter";
private boolean epochInSeconds = true;
}
| 1,891 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/ThriftProperties.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.Data;
/**
* Properties related to Thrift.
*
* @author tgianos
* @since 1.1.0
*/
@Data
//TODO: This should be in the Thrift module
public class ThriftProperties {
private int serverMaxWorkerThreads = 100;
private int serverSocketClientTimeoutInSeconds = 60;
}
| 1,892 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/MetacatProperties.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.NonNull;
/**
* Entry point to entire property tree of Metacat namespace.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public class MetacatProperties {
@NonNull
private Data data = new Data();
@NonNull
private Definition definition = new Definition();
@NonNull
private ElasticsearchProperties elasticsearch = new ElasticsearchProperties();
@NonNull
private EventProperties event = new EventProperties();
@NonNull
private FranklinProperties franklin = new FranklinProperties();
@NonNull
private HiveProperties hive = new HiveProperties();
@NonNull
private LookupServiceProperties lookupService = new LookupServiceProperties();
@NonNull
private NotificationsProperties notifications = new NotificationsProperties();
@NonNull
private PluginProperties plugin = new PluginProperties();
@NonNull
private ServiceProperties service = new ServiceProperties();
@NonNull
private Table table = new Table();
@NonNull
private TagServiceProperties tagService = new TagServiceProperties();
@NonNull
private ThriftProperties thrift = new ThriftProperties();
@NonNull
private TypeProperties type = new TypeProperties();
@NonNull
private User user = new User();
@NonNull
private UserMetadata usermetadata = new UserMetadata();
@NonNull
private CacheProperties cache = new CacheProperties();
@NonNull
private AuthorizationServiceProperties authorization = new AuthorizationServiceProperties();
@NonNull
private AliasServiceProperties aliasServiceProperties = new AliasServiceProperties();
@NonNull
private RateLimiterProperties rateLimiterProperties = new RateLimiterProperties();
}
| 1,893 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/Table.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.base.Splitter;
import lombok.NonNull;
import org.apache.commons.lang3.StringUtils;
import java.util.HashSet;
import java.util.Set;
/**
* Table related properties.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public class Table {
@NonNull
private Delete delete = new Delete();
@NonNull
private Rename rename = new Rename();
@NonNull
private Update update = new Update();
/**
* Delete related properties.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public static class Delete {
@NonNull
private Cascade cascade = new Cascade();
private String noDeleteOnTags;
private Set<String> noDeleteOnTagsSet;
/**
* Get the tags that disable table deletes.
*
* @return Set of tags
*/
@JsonIgnore
public Set<String> getNoDeleteOnTagsSet() {
if (noDeleteOnTagsSet == null) {
if (StringUtils.isNotBlank(noDeleteOnTags)) {
noDeleteOnTagsSet = new HashSet<>(Splitter.on(',')
.omitEmptyStrings()
.splitToList(noDeleteOnTags));
} else {
noDeleteOnTagsSet = new HashSet<>();
}
}
return noDeleteOnTagsSet;
}
/**
* Cascade related properties.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public static class Cascade {
@NonNull
private Views views = new Views();
/**
* Views related properties.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public static class Views {
private boolean metadata = true;
}
}
}
/**
* Rename related properties.
*
* @author amajumdar
* @since 1.3.0
*/
@lombok.Data
public static class Rename {
private String noRenameOnTags;
private Set<String> noRenameOnTagsSet;
/**
* Get the tags that disable table renames.
*
* @return Set of tags
*/
@JsonIgnore
public Set<String> getNoRenameOnTagsSet() {
if (noRenameOnTagsSet == null) {
if (StringUtils.isNotBlank(noRenameOnTags)) {
noRenameOnTagsSet = new HashSet<>(Splitter.on(',')
.omitEmptyStrings()
.splitToList(noRenameOnTags));
} else {
noRenameOnTagsSet = new HashSet<>();
}
}
return noRenameOnTagsSet;
}
}
/**
* Update related properties.
*/
@lombok.Data
public static class Update {
private String noUpdateOnTags;
private Set<String> noUpdateOnTagsSet;
/**
* Get the tags that disable table updates.
*
* @return Set of tags
*/
@JsonIgnore
public Set<String> getNoUpdateOnTagsSet() {
if (noUpdateOnTagsSet == null) {
if (StringUtils.isNotBlank(noUpdateOnTags)) {
noUpdateOnTagsSet = new HashSet<>(Splitter.on(',')
.omitEmptyStrings()
.trimResults()
.splitToList(noUpdateOnTags));
} else {
noUpdateOnTagsSet = new HashSet<>();
}
}
return noUpdateOnTagsSet;
}
}
}
| 1,894 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/User.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.Data;
import lombok.NonNull;
/**
* User related properties for metacat.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public class User {
@NonNull
private Metadata metadata = new Metadata();
/**
* Metadata related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Metadata {
private boolean softDelete = true;
private int maxInClauseItems = 2500;
}
}
| 1,895 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/EventProperties.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.Data;
import lombok.NonNull;
/**
* Properties related to Metacat internal Events.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public class EventProperties {
private boolean updateIcebergTableAsyncPostEventEnabled;
@NonNull
private Thread thread = new Thread();
@NonNull
private Bus bus = new Bus();
/**
* Properties related to event threads.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Thread {
private int count = 10;
}
/**
* Properties related to the event bus.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Bus {
@NonNull
private Executor executor = new Executor();
/**
* Properties related to bus executor.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Executor {
@NonNull
private Thread thread = new Thread();
/**
* Properties related to event bus executor threads.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Thread {
private int count = 10;
}
}
}
}
| 1,896 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/Data.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.NonNull;
/**
* Data related properties.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public class Data {
@NonNull
private Metadata metadata = new Metadata();
/**
* Metadata related properties.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public static class Metadata {
@NonNull
private Delete delete = new Delete();
/**
* Delete related properties.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public static class Delete {
private boolean enable;
@NonNull
private Marker marker = new Marker();
/**
* Marker related properties.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public static class Marker {
@NonNull
private Lifetime lifetime = new Lifetime();
/**
* Lifetime related properties.
*
* @author tgianos
* @since 1.1.0
*/
@lombok.Data
public static class Lifetime {
private int days = 15;
}
}
}
}
}
| 1,897 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/FranklinProperties.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import lombok.Data;
import lombok.NonNull;
/**
* Franklin related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public class FranklinProperties {
@NonNull
private Connector connector = new Connector();
/**
* Connector related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Connector {
@NonNull
private Use use = new Use();
/**
* Connector use related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Use {
@NonNull
private Pig pig = new Pig();
/**
* Connector use pig related properties.
*
* @author tgianos
* @since 1.1.0
*/
@Data
public static class Pig {
private boolean type = true;
}
}
}
}
| 1,898 |
0 |
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server
|
Create_ds/metacat/metacat-common-server/src/main/java/com/netflix/metacat/common/server/properties/DefaultConfigImpl.java
|
/*
*
* Copyright 2017 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://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.server.properties;
import com.netflix.metacat.common.QualifiedName;
import lombok.NonNull;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* A default implementation of the config interface.
*
* @author tgianos
* @since 1.1.0
*/
public class DefaultConfigImpl implements Config {
private final MetacatProperties metacatProperties;
/**
* Constructor.
*
* @param metacatProperties The metacat properties to use
*/
public DefaultConfigImpl(@Nonnull @NonNull final MetacatProperties metacatProperties) {
this.metacatProperties = metacatProperties;
}
/**
* {@inheritDoc}
*/
@Override
public String getDefaultTypeConverter() {
return this.metacatProperties.getType().getConverter();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isElasticSearchEnabled() {
return this.metacatProperties.getElasticsearch().isEnabled();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isElasticSearchUpdateTablesWithSameUriEnabled() {
return this.metacatProperties.getElasticsearch().getPublish().isUpdateTablesWithSameUriEnabled();
}
@Override
public boolean isElasticSearchPublishPartitionEnabled() {
return this.metacatProperties.getElasticsearch().getPublish().isPartitionEnabled();
}
@Override
public boolean isElasticSearchPublishMetacatLogEnabled() {
return this.metacatProperties.getElasticsearch().getPublish().isMetacatLogEnabled();
}
/**
* {@inheritDoc}
*/
@Override
public String getElasticSearchClusterName() {
return this.metacatProperties.getElasticsearch().getCluster().getName();
}
/**
* {@inheritDoc}
*/
@Override
public String getElasticSearchClusterNodes() {
return this.metacatProperties.getElasticsearch().getCluster().getNodes();
}
/**
* {@inheritDoc}
*/
@Override
public int getElasticSearchClusterPort() {
return this.metacatProperties.getElasticsearch().getCluster().getPort();
}
/**
* {@inheritDoc}
*/
@Override
public int getElasticSearchScrollFetchSize() {
return this.metacatProperties.getElasticsearch().getScroll().getFetch().getSize();
}
/**
* {@inheritDoc}
*/
@Override
public int getElasticSearchScrollTimeout() {
return this.metacatProperties.getElasticsearch().getScroll().getTimeout().getMs();
}
/**
* {@inheritDoc}
*/
@Override
public long getElasticSearchCallTimeout() {
return this.metacatProperties.getElasticsearch().getTimeout();
}
/**
* {@inheritDoc}
*/
@Override
public long getElasticSearchBulkCallTimeout() {
return this.metacatProperties.getElasticsearch().getBulkTimeout();
}
/**
* {@inheritDoc}
*/
@Override
public List<QualifiedName> getElasticSearchRefreshExcludeQualifiedNames() {
return this.metacatProperties
.getElasticsearch()
.getRefresh()
.getExclude()
.getQualified()
.getNamesAsListOfQualifiedNames();
}
/**
* {@inheritDoc}
*/
@Override
public String getElasticSearchRefreshIncludeCatalogs() {
return this.metacatProperties.getElasticsearch().getRefresh().getInclude().getCatalogs();
}
/**
* {@inheritDoc}
*/
@Override
public List<QualifiedName> getElasticSearchRefreshIncludeDatabases() {
return this.metacatProperties.getElasticsearch().getRefresh().getInclude().getDatabasesAsListOfQualfiedNames();
}
/**
* {@inheritDoc}
*/
@Override
public String getElasticSearchRefreshPartitionsIncludeCatalogs() {
return this.metacatProperties.getElasticsearch().getRefresh().getPartitions().getInclude().getCatalogs();
}
/**
* {@inheritDoc}
*/
@Override
public int getElasticSearchThresholdUnmarkedDatabasesDelete() {
return this.metacatProperties
.getElasticsearch()
.getRefresh()
.getThreshold()
.getUnmarked()
.getDatabases()
.getDelete();
}
/**
* {@inheritDoc}
*/
@Override
public int getElasticSearchThresholdUnmarkedTablesDelete() {
return this.metacatProperties
.getElasticsearch()
.getRefresh()
.getThreshold()
.getUnmarked()
.getTables()
.getDelete();
}
/**
* {@inheritDoc}
*/
@Override
public int getEventBusExecutorThreadCount() {
return this.metacatProperties.getEvent().getBus().getExecutor().getThread().getCount();
}
/**
* {@inheritDoc}
*/
@Override
public int getEventBusThreadCount() {
return this.metacatProperties.getEvent().getThread().getCount();
}
/**
* {@inheritDoc}
*/
@Override
public String getHivePartitionWhitelistPattern() {
return this.metacatProperties.getHive().getMetastore().getPartition().getName().getWhitelist().getPattern();
}
/**
* {@inheritDoc}
*/
@Override
public boolean escapePartitionNameOnFilter() {
return this.metacatProperties.getHive().getMetastore().getPartition().isEscapeNameOnFilter();
}
/**
* {@inheritDoc}
*/
@Override
public int getHiveMetastoreFetchSize() {
return this.metacatProperties.getHive().getMetastore().getFetchSize();
}
/**
* {@inheritDoc}
*/
@Override
public int getHiveMetastoreBatchSize() {
return this.metacatProperties.getHive().getMetastore().getBatchSize();
}
/**
* {@inheritDoc}
*/
@Override
public String getLookupServiceUserAdmin() {
return this.metacatProperties.getLookupService().getUserAdmin();
}
/**
* {@inheritDoc}
*/
@Override
public String getMetacatVersion() {
// TODO
throw new UnsupportedOperationException("Not yet implemented");
}
/**
* {@inheritDoc}
*/
@Override
public String getPluginConfigLocation() {
return this.metacatProperties.getPlugin().getConfig().getLocation();
}
/**
* {@inheritDoc}
*/
@Override
public String getTagServiceUserAdmin() {
return this.metacatProperties.getTagService().getUserAdmin();
}
/**
* {@inheritDoc}
*/
@Override
public int getThriftServerMaxWorkerThreads() {
return this.metacatProperties.getThrift().getServerMaxWorkerThreads();
}
/**
* {@inheritDoc}
*/
@Override
public int getThriftServerSocketClientTimeoutInSeconds() {
return this.metacatProperties.getThrift().getServerSocketClientTimeoutInSeconds();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isEpochInSeconds() {
return this.metacatProperties.getType().isEpochInSeconds();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isUsePigTypes() {
return this.metacatProperties.getFranklin().getConnector().getUse().getPig().isType();
}
/**
* {@inheritDoc}
*/
@Override
public int getServiceMaxNumberOfThreads() {
return this.metacatProperties.getService().getMax().getNumber().getThreads();
}
/**
* {@inheritDoc}
*/
@Override
public List<QualifiedName> getNamesToThrowErrorOnListPartitionsWithNoFilter() {
return this.metacatProperties
.getService()
.getTables()
.getError()
.getList()
.getPartitions()
.getNo()
.getFilterAsListOfQualifiedNames();
}
/**
* {@inheritDoc}
*/
@Override
public int getMaxPartitionsThreshold() {
return this.metacatProperties
.getService()
.getTables()
.getError()
.getList()
.getPartitions()
.getThreshold();
}
/**
* {@inheritDoc}
*/
@Override
public int getMaxAddedPartitionsThreshold() {
return this.metacatProperties
.getService()
.getTables()
.getError()
.getList()
.getPartitions()
.getAddThreshold();
}
/**
* {@inheritDoc}
*/
@Override
public int getMaxDeletedPartitionsThreshold() {
return this.metacatProperties
.getService()
.getTables()
.getError()
.getList()
.getPartitions()
.getDeleteThreshold();
}
/**
* {@inheritDoc}
*/
@Override
public String getEsIndex() {
return this.metacatProperties.getElasticsearch().getIndex().getName();
}
/**
* {@inheritDoc}
*/
@Override
public String getMergeEsIndex() {
return this.metacatProperties.getElasticsearch().getMergeIndex().getName();
}
/**
* {@inheritDoc}
*/
@Override
public int getDataMetadataDeleteMarkerLifetimeInDays() {
return this.metacatProperties.getData().getMetadata().getDelete().getMarker().getLifetime().getDays();
}
/**
* {@inheritDoc}
*/
@Override
public boolean canSoftDeleteDataMetadata() {
return this.metacatProperties.getUser().getMetadata().isSoftDelete();
}
/**
* {@inheritDoc}
*/
@Override
public boolean canCascadeViewsMetadataOnTableDelete() {
return this.metacatProperties.getTable().getDelete().getCascade().getViews().isMetadata();
}
/**
* {@inheritDoc}
*/
@Override
public int getUserMetadataMaxInClauseItems() {
return this.metacatProperties.getUser().getMetadata().getMaxInClauseItems();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isSnsNotificationEnabled() {
return this.metacatProperties.getNotifications().getSns().isEnabled();
}
/**
* {@inheritDoc}
*/
@Override
public String getSnsTopicTableArn() {
return this.metacatProperties.getNotifications().getSns().getTopic().getTable().getArn();
}
/**
* {@inheritDoc}
*/
@Override
public String getSnsTopicPartitionArn() {
return this.metacatProperties.getNotifications().getSns().getTopic().getPartition().getArn();
}
@Override
public String getFallbackSnsTopicTableArn() {
return this.metacatProperties.getNotifications().getSns().getTopic().getTable().getFallbackArn();
}
@Override
public String getFallbackSnsTopicPartitionArn() {
return this.metacatProperties.getNotifications().getSns().getTopic().getPartition().getFallbackArn();
}
@Override
public boolean isSnsNotificationTopicPartitionEnabled() {
return this.metacatProperties.getNotifications().getSns().getTopic().getPartition().isEnabled();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isSnsNotificationAttachPartitionIdsEnabled() {
return this.metacatProperties.getNotifications().getSns().getAttachPartitionIds().isEnabled();
}
/**
* {@inheritDoc}
*/
@Override
public int getSnsNotificationAttachPartitionIdMax() {
return this.metacatProperties.getNotifications().getSns().getAttachPartitionIds().getMaxPartitionIdNumber();
}
@Override
public boolean canDeleteTableDefinitionMetadata() {
return this.metacatProperties.getDefinition().getMetadata().getDelete().isEnableForTable();
}
@Override
public Set<QualifiedName> getNamesEnabledForDefinitionMetadataDelete() {
return this.metacatProperties.getDefinition().getMetadata().getDelete().getQualifiedNamesEnabledForDelete();
}
@Override
public boolean isCacheEnabled() {
return this.metacatProperties.getCache().isEnabled();
}
@Override
public boolean isAuthorizationEnabled() {
return this.metacatProperties.getAuthorization().isEnabled();
}
@Override
public Map<QualifiedName, Set<String>> getMetacatCreateAcl() {
return this.metacatProperties.getAuthorization().getCreateAcl().getCreateAclMap();
}
@Override
public Map<QualifiedName, Set<String>> getMetacatDeleteAcl() {
return this.metacatProperties.getAuthorization().getDeleteAcl().getDeleteAclMap();
}
/**
* {@inheritDoc}
*/
@Override
public int getIcebergTableSummaryFetchSize() {
return this.metacatProperties.getHive().getIceberg().getFetchSizeInTableSummary();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isIcebergEnabled() {
return this.metacatProperties.getHive().getIceberg().isEnabled();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isIcebergCacheEnabled() {
return this.metacatProperties.getHive().getIceberg().getCache().isEnabled();
}
@Override
public boolean isIcebergTableMetadataCacheEnabled() {
return this.metacatProperties.getHive().getIceberg().getCache().getMetadata().isEnabled();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isCommonViewEnabled() {
return this.metacatProperties.getHive().getCommonview().isEnabled();
}
/**
* {@inheritDoc}
*/
@Override
public boolean deleteCommonViewStorageTable() {
return this.metacatProperties.getHive().getCommonview().isDeleteStorageTable();
}
/**
* {@inheritDoc}
*/
@Override
public int getIcebergRefreshFromMetadataLocationRetryNumber() {
return this.metacatProperties.getHive().getIceberg().getRefreshFromMetadataLocationRetryNumber();
}
/**
* {@inheritDoc}
*/
@Override
public long getIcebergMaxMetadataFileSize() {
return this.metacatProperties.getHive().getIceberg().getMaxMetadataFileSizeBytes();
}
/**
* {@inheritDoc}
*/
@Override
public String getIcebergPartitionUriScheme() {
return this.metacatProperties.getHive().getIceberg().getPartitionUriScheme();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isTableAliasEnabled() {
return this.metacatProperties.getAliasServiceProperties().isEnabled();
}
@Override
public Set<String> getNoTableDeleteOnTags() {
return this.metacatProperties.getTable().getDelete().getNoDeleteOnTagsSet();
}
@Override
public Set<String> getNoTableRenameOnTags() {
return this.metacatProperties.getTable().getRename().getNoRenameOnTagsSet();
}
@Override
public Set<String> getNoTableUpdateOnTags() {
return this.metacatProperties.getTable().getUpdate().getNoUpdateOnTagsSet();
}
/**
* Whether the rate limiter is enabled.
*
* @return True if it is.
*/
@Override
public boolean isRateLimiterEnabled() {
return this.metacatProperties.getRateLimiterProperties().isEnabled();
}
/**
* Whether the rate limiter is being enforced
* and rejecting requests.
*
* @return True if it is.
*/
public boolean isRateLimiterEnforced() {
return this.metacatProperties.getRateLimiterProperties().isEnforced();
}
@Override
public boolean isUpdateIcebergTableAsyncPostEventEnabled() {
return this.metacatProperties.getEvent().isUpdateIcebergTableAsyncPostEventEnabled();
}
@Override
public boolean listTableNamesByDefaultOnGetDatabase() {
return this.metacatProperties.getService().isListTableNamesByDefaultOnGetDatabase();
}
@Override
public boolean listDatabaseNameByDefaultOnGetCatalog() {
return this.metacatProperties.getService().isListDatabaseNameByDefaultOnGetCatalog();
}
@Override
public int getMetadataQueryTimeout() {
return this.metacatProperties.getUsermetadata().getQueryTimeoutInSeconds();
}
@Override
public boolean isIcebergPreviousMetadataLocationCheckEnabled() {
return this.metacatProperties.getHive().getIceberg().isIcebergPreviousMetadataLocationCheckEnabled();
}
@Override
public boolean disablePartitionDefinitionMetadata() {
return this.metacatProperties.getDefinition().getMetadata().isDisablePartitionDefinitionMetadata();
}
@Override
public boolean shouldFetchOnlyMetadataLocationEnabled() {
return this.metacatProperties.getHive().getIceberg().isShouldFetchOnlyMetadataLocationEnabled();
}
}
| 1,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.