Search in sources :

Example 1 with ConnectionStore

use of io.cdap.cdap.datapipeline.connection.ConnectionStore in project cdap by caskdata.

the class ConnectionHandler method initialize.

@Override
public void initialize(SystemHttpServiceContext context) throws Exception {
    super.initialize(context);
    contextAccessEnforcer = context.getContextAccessEnforcer();
    store = new ConnectionStore(context);
    String disabledTypesStr = context.getSpecification().getProperty(DISABLED_TYPES);
    this.disabledTypes = GSON.fromJson(disabledTypesStr, SET_STRING_TYPE);
}
Also used : ConnectionStore(io.cdap.cdap.datapipeline.connection.ConnectionStore)

Example 2 with ConnectionStore

use of io.cdap.cdap.datapipeline.connection.ConnectionStore in project cdap by caskdata.

the class StudioService method createPreconfiguredConnections.

private void createPreconfiguredConnections(SystemServiceContext context) throws IOException {
    ConnectionStore connectionStore = new ConnectionStore(context);
    for (PreconfiguredConnectionCreationRequest creationRequest : connectionConfig.getConnections()) {
        if (creationRequest.getName() == null || creationRequest.getNamespace() == null) {
            continue;
        }
        NamespaceSummary namespaceSummary = context.getAdmin().getNamespaceSummary(creationRequest.getNamespace());
        if (namespaceSummary == null) {
            LOG.warn("Namespace {} does not exist, skipping creating connection {}", creationRequest.getNamespace(), creationRequest.getName());
        }
        ConnectionId connectionId = new ConnectionId(namespaceSummary, creationRequest.getName());
        long now = System.currentTimeMillis();
        Connection connectionInfo = new Connection(creationRequest.getName(), connectionId.getConnectionId(), creationRequest.getPlugin().getName(), creationRequest.getDescription(), true, creationRequest.getName().equals(connectionConfig.getDefaultConnection()) ? true : false, now, now, creationRequest.getPlugin());
        try {
            connectionStore.saveConnection(connectionId, connectionInfo, false);
        } catch (ConnectionConflictException e) {
        // expected if the connection is already created
        }
    }
}
Also used : ConnectionConflictException(io.cdap.cdap.etl.proto.connection.ConnectionConflictException) ConnectionId(io.cdap.cdap.etl.proto.connection.ConnectionId) Connection(io.cdap.cdap.etl.proto.connection.Connection) NamespaceSummary(io.cdap.cdap.api.NamespaceSummary) ConnectionStore(io.cdap.cdap.datapipeline.connection.ConnectionStore) PreconfiguredConnectionCreationRequest(io.cdap.cdap.etl.proto.connection.PreconfiguredConnectionCreationRequest)

Aggregations

ConnectionStore (io.cdap.cdap.datapipeline.connection.ConnectionStore)2 NamespaceSummary (io.cdap.cdap.api.NamespaceSummary)1 Connection (io.cdap.cdap.etl.proto.connection.Connection)1 ConnectionConflictException (io.cdap.cdap.etl.proto.connection.ConnectionConflictException)1 ConnectionId (io.cdap.cdap.etl.proto.connection.ConnectionId)1 PreconfiguredConnectionCreationRequest (io.cdap.cdap.etl.proto.connection.PreconfiguredConnectionCreationRequest)1