Search in sources :

Example 1 with CreateTableWithOptions

use of com.datastax.oss.driver.api.querybuilder.schema.CreateTableWithOptions in project janusgraph by JanusGraph.

the class CQLKeyColumnValueStoreTest method testCompactionStrategyWithOptions.

@Test
public void testCompactionStrategyWithOptions() {
    CreateTableWithOptions createTable = createTable("tableName").withPartitionKey("column", DataTypes.BLOB);
    Configuration configuration = buildGraphConfiguration().set(COMPACTION_OPTIONS, new String[] { "enabled", "false" }).set(COMPACTION_STRATEGY, "LeveledCompactionStrategy");
    assertDoesNotThrow(() -> {
        CQLKeyColumnValueStore.compactionOptions(createTable, configuration);
    });
}
Also used : Configuration(org.janusgraph.diskstorage.configuration.Configuration) GraphDatabaseConfiguration.buildGraphConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.buildGraphConfiguration) CreateTableWithOptions(com.datastax.oss.driver.api.querybuilder.schema.CreateTableWithOptions) Test(org.junit.Test)

Example 2 with CreateTableWithOptions

use of com.datastax.oss.driver.api.querybuilder.schema.CreateTableWithOptions in project janusgraph by JanusGraph.

the class CQLKeyColumnValueStore method initializeTable.

private static void initializeTable(final CqlSession session, final String keyspaceName, final String tableName, final Configuration configuration) {
    CreateTableWithOptions createTable = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(KEY_COLUMN_NAME, DataTypes.BLOB).withClusteringColumn(COLUMN_COLUMN_NAME, DataTypes.BLOB).withColumn(VALUE_COLUMN_NAME, DataTypes.BLOB);
    createTable = compactionOptions(createTable, configuration);
    createTable = compressionOptions(createTable, configuration);
    createTable = gcGraceSeconds(createTable, configuration);
    createTable = speculativeRetryOptions(createTable, configuration);
    session.execute(createTable.build());
}
Also used : CreateTableWithOptions(com.datastax.oss.driver.api.querybuilder.schema.CreateTableWithOptions)

Example 3 with CreateTableWithOptions

use of com.datastax.oss.driver.api.querybuilder.schema.CreateTableWithOptions in project janusgraph by JanusGraph.

the class CQLKeyColumnValueStoreTest method testCompactionStrategyWithoutOptions.

@Test
public void testCompactionStrategyWithoutOptions() {
    CreateTableWithOptions createTable = createTable("tableName").withPartitionKey("column", DataTypes.BLOB);
    Configuration configuration = buildGraphConfiguration().set(COMPACTION_STRATEGY, "LeveledCompactionStrategy");
    assertDoesNotThrow(() -> {
        CQLKeyColumnValueStore.compactionOptions(createTable, configuration);
    });
}
Also used : Configuration(org.janusgraph.diskstorage.configuration.Configuration) GraphDatabaseConfiguration.buildGraphConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.buildGraphConfiguration) CreateTableWithOptions(com.datastax.oss.driver.api.querybuilder.schema.CreateTableWithOptions) Test(org.junit.Test)

Example 4 with CreateTableWithOptions

use of com.datastax.oss.driver.api.querybuilder.schema.CreateTableWithOptions in project archiva by apache.

the class DefaultCassandraArchivaManager method initialize.

@PostConstruct
public void initialize() {
    // skip initialisation if not cassandra
    if (!StringUtils.equals(repositorySessionFactoryBean.getId(), "cassandra")) {
        return;
    }
    List<String> hostNames = new ArrayList<>();
    hostNames.add(cassandraHost + ":" + cassandraPort);
    configLoader = DriverConfigLoader.programmaticBuilder().withStringList(DefaultDriverOption.CONTACT_POINTS, hostNames).withInt(DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE, maxActive).withInt(DefaultDriverOption.CONNECTION_POOL_REMOTE_SIZE, maxActive).withString(DefaultDriverOption.REQUEST_CONSISTENCY, readConsistencyLevel).withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofMillis(driverTimeoutMs)).build();
    {
        CreateKeyspace cKeySpace = createKeyspace(keyspaceName).ifNotExists().withSimpleStrategy(replicationFactor);
        CqlSession.builder().withConfigLoader(configLoader).withLocalDatacenter("datacenter1").build().execute(cKeySpace.build());
    }
    CqlSession session = getSession();
    {
        // namespace table
        {
            String tableName = getNamespaceFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(CassandraArchivaManager.DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn(NAME.toString(), DataTypes.TEXT).withColumn(REPOSITORY_NAME.toString(), DataTypes.TEXT).withCompactStorage();
            session.execute(table.build());
            CreateIndex index = createIndex(NAME.toString()).ifNotExists().onTable(tableName).andColumn(NAME.toString());
            session.execute(index.build());
            index = createIndex(REPOSITORY_NAME.toString()).ifNotExists().onTable(tableName).andColumn(REPOSITORY_NAME.toString());
            session.execute(index.build());
        }
        // Repository Table
        {
            String tableName = getRepositoryFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(CassandraArchivaManager.DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn(REPOSITORY_NAME.toString(), DataTypes.TEXT).withCompactStorage();
            session.execute(table.build());
            CreateIndex index = createIndex(REPOSITORY_NAME.toString()).ifNotExists().onTable(tableName).andColumn(REPOSITORY_NAME.toString());
            session.execute(index.build());
        }
        // Project table
        {
            String tableName = getProjectFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(CassandraArchivaManager.DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn(PROJECT_ID.toString(), DataTypes.TEXT).withColumn(REPOSITORY_NAME.toString(), DataTypes.TEXT).withColumn(NAMESPACE_ID.toString(), DataTypes.TEXT).withColumn(PROJECT_PROPERTIES.toString(), DataTypes.frozenMapOf(DataTypes.TEXT, DataTypes.TEXT)).withCompactStorage();
            session.execute(table.build());
            CreateIndex index = createIndex(PROJECT_ID.toString()).ifNotExists().onTable(tableName).andColumn(PROJECT_ID.toString());
            session.execute(index.build());
            index = createIndex(REPOSITORY_NAME.toString()).ifNotExists().onTable(tableName).andColumn(REPOSITORY_NAME.toString());
            session.execute(index.build());
            index = createIndex(NAMESPACE_ID.toString()).ifNotExists().onTable(tableName).andColumn(NAMESPACE_ID.toString());
            session.execute(index.build());
        }
        // Project Version Metadata Model
        {
            String tableName = getProjectVersionMetadataFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(CassandraArchivaManager.DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn(NAMESPACE_ID.toString(), DataTypes.TEXT).withColumn(REPOSITORY_NAME.toString(), DataTypes.TEXT).withColumn(PROJECT_VERSION.toString(), DataTypes.TEXT).withColumn(PROJECT_ID.toString(), DataTypes.TEXT).withColumn(DESCRIPTION.toString(), DataTypes.TEXT).withColumn(URL.toString(), DataTypes.TEXT).withColumn(NAME.toString(), DataTypes.TEXT).withColumn(VERSION.toString(), DataTypes.TEXT).withColumn(VERSION_PROPERTIES.toString(), DataTypes.mapOf(DataTypes.TEXT, DataTypes.TEXT)).withColumn("incomplete", DataTypes.BOOLEAN).withColumn("\"ciManagement.system\"", DataTypes.TEXT).withColumn("\"ciManagement.url\"", DataTypes.TEXT).withColumn("\"issueManagement.system\"", DataTypes.TEXT).withColumn("\"issueManagement.url\"", DataTypes.TEXT).withColumn("\"organization.name\"", DataTypes.TEXT).withColumn("\"organization.url\"", DataTypes.TEXT).withColumn("\"scm.url\"", DataTypes.TEXT).withColumn("\"scm.connection\"", DataTypes.TEXT).withColumn("\"scm.developerConnection\"", DataTypes.TEXT);
            session.execute(table.build());
            CreateIndex index = createIndex(NAMESPACE_ID.toString()).ifNotExists().onTable(tableName).andColumn(NAMESPACE_ID.toString());
            session.execute(index.build());
            index = createIndex(REPOSITORY_NAME.toString()).ifNotExists().onTable(tableName).andColumn(REPOSITORY_NAME.toString());
            session.execute(index.build());
            index = createIndex(PROJECT_VERSION.toString()).ifNotExists().onTable(tableName).andColumn(PROJECT_VERSION.toString());
            session.execute(index.build());
            index = createIndex(PROJECT_ID.toString()).ifNotExists().onTable(tableName).andColumn(PROJECT_ID.toString());
            session.execute(index.build());
            index = createIndex(VERSION_PROPERTIES.toString() + "_idx").ifNotExists().onTable(tableName).andColumnEntries(VERSION_PROPERTIES.toString());
            session.execute(index.build());
        }
        // Artifact Metadata Model
        {
            String tableName = getArtifactMetadataFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(CassandraArchivaManager.DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn(ID.toString(), DataTypes.TEXT).withColumn(REPOSITORY_NAME.toString(), DataTypes.TEXT).withColumn(NAMESPACE_ID.toString(), DataTypes.TEXT).withColumn(PROJECT_ID.toString(), DataTypes.TEXT).withColumn(PROJECT_VERSION.toString(), DataTypes.TEXT).withColumn(VERSION.toString(), DataTypes.TEXT).withColumn(WHEN_GATHERED.toString(), DataTypes.BIGINT).withColumn(SHA1.toString(), DataTypes.TEXT).withColumn(MD5.toString(), DataTypes.TEXT).withColumn(FILE_LAST_MODIFIED.toString(), DataTypes.BIGINT).withColumn(SIZE.toString(), DataTypes.BIGINT).withCompactStorage();
            session.execute(table.build());
            CreateIndex index = createIndex(ID.toString()).ifNotExists().onTable(tableName).andColumn(ID.toString());
            session.execute(index.build());
            index = createIndex(REPOSITORY_NAME.toString()).ifNotExists().onTable(tableName).andColumn(REPOSITORY_NAME.toString());
            session.execute(index.build());
            index = createIndex(NAMESPACE_ID.toString()).ifNotExists().onTable(tableName).andColumn(NAMESPACE_ID.toString());
            session.execute(index.build());
            index = createIndex(PROJECT_ID.toString()).ifNotExists().onTable(tableName).andColumn(PROJECT_ID.toString());
            session.execute(index.build());
            index = createIndex(PROJECT_VERSION.toString()).ifNotExists().onTable(tableName).andColumn(PROJECT_VERSION.toString());
            session.execute(index.build());
            index = createIndex(VERSION.toString()).ifNotExists().onTable(tableName).andColumn(VERSION.toString());
            session.execute(index.build());
            index = createIndex(WHEN_GATHERED.toString()).ifNotExists().onTable(tableName).andColumn(WHEN_GATHERED.toString());
            session.execute(index.build());
            index = createIndex(SHA1.toString()).ifNotExists().onTable(tableName).andColumn(SHA1.toString());
            session.execute(index.build());
            index = createIndex(MD5.toString()).ifNotExists().onTable(tableName).andColumn(MD5.toString());
            session.execute(index.build());
        }
        // Metadata Facet Model
        {
            String tableName = getMetadataFacetFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(CassandraArchivaManager.DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn(FACET_ID.toString(), DataTypes.TEXT).withColumn(REPOSITORY_NAME.toString(), DataTypes.TEXT).withColumn(NAME.toString(), DataTypes.TEXT).withColumn(NAMESPACE_ID.toString(), DataTypes.TEXT).withColumn(PROJECT_ID.toString(), DataTypes.TEXT).withColumn(PROJECT_VERSION.toString(), DataTypes.TEXT).withColumn(KEY.toString(), DataTypes.TEXT).withColumn(VALUE.toString(), DataTypes.TEXT).withColumn(WHEN_GATHERED.toString(), DataTypes.BIGINT).withCompactStorage();
            session.execute(table.build());
            CreateIndex index = createIndex(FACET_ID.toString()).ifNotExists().onTable(tableName).andColumn(FACET_ID.toString());
            session.execute(index.build());
            index = createIndex(REPOSITORY_NAME.toString()).ifNotExists().onTable(tableName).andColumn(REPOSITORY_NAME.toString());
            session.execute(index.build());
            index = createIndex(NAME.toString()).ifNotExists().onTable(tableName).andColumn(NAME.toString());
            session.execute(index.build());
            index = createIndex(NAMESPACE_ID.toString()).ifNotExists().onTable(tableName).andColumn(NAMESPACE_ID.toString());
            session.execute(index.build());
            index = createIndex(PROJECT_ID.toString()).ifNotExists().onTable(tableName).andColumn(PROJECT_ID.toString());
            session.execute(index.build());
            index = createIndex(PROJECT_VERSION.toString()).ifNotExists().onTable(tableName).andColumn(PROJECT_VERSION.toString());
            session.execute(index.build());
        }
        // Checksum Table
        {
            String tableName = getChecksumFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn("\"artifactMetadataModel.key\"", DataTypes.TEXT).withColumn(CHECKSUM_ALG.toString(), DataTypes.TEXT).withColumn(CHECKSUM_VALUE.toString(), DataTypes.TEXT).withColumn(REPOSITORY_NAME.toString(), DataTypes.TEXT).withCompactStorage();
            session.execute(table.build());
            CreateIndex index = createIndex(CHECKSUM_ALG.toString()).ifNotExists().onTable(tableName).andColumn(CHECKSUM_ALG.toString());
            session.execute(index.build());
            index = createIndex(CHECKSUM_VALUE.toString()).ifNotExists().onTable(tableName).andColumn(CHECKSUM_VALUE.toString());
            session.execute(index.build());
            index = createIndex(REPOSITORY_NAME.toString()).ifNotExists().onTable(tableName).andColumn(REPOSITORY_NAME.toString());
            session.execute(index.build());
        }
        // Mailinglist Table
        {
            String tableName = getMailingListFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(CassandraArchivaManager.DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn(NAME.toString(), DataTypes.TEXT).withColumn("\"projectVersionMetadataModel.key\"", DataTypes.TEXT).withColumn("mainArchiveUrl", DataTypes.TEXT).withColumn("postAddress", DataTypes.TEXT).withColumn("subscribeAddress", DataTypes.TEXT).withColumn("unsubscribeAddress", DataTypes.TEXT).withColumn("otherArchive", DataTypes.frozenListOf(DataTypes.TEXT)).withCompactStorage();
            session.execute(table.build());
            CreateIndex index = createIndex("\"projectVersionMetadataModel_key\"").ifNotExists().onTable(tableName).andColumn("\"\"projectVersionMetadataModel.key\"\"");
            session.execute(index.build());
        }
        // License Table
        {
            String tableName = getLicenseFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(CassandraArchivaManager.DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn("\"projectVersionMetadataModel.key\"", DataTypes.TEXT).withColumn(NAME.toString(), DataTypes.TEXT).withColumn(URL.toString(), DataTypes.TEXT).withCompactStorage();
            session.execute(table.build());
            CreateIndex index = createIndex("\"projectVersionMetadataModel_key\"").ifNotExists().onTable(tableName).andColumn("\"\"projectVersionMetadataModel.key\"\"");
            session.execute(index.build());
        }
        // Dependency Table
        {
            String tableName = getDependencyFamilyName();
            CreateTableWithOptions table = createTable(keyspaceName, tableName).ifNotExists().withPartitionKey(CassandraArchivaManager.DEFAULT_PRIMARY_KEY, DataTypes.TEXT).withColumn(REPOSITORY_NAME.toString(), DataTypes.TEXT).withColumn(GROUP_ID.toString(), DataTypes.TEXT).withColumn(ARTIFACT_ID.toString(), DataTypes.TEXT).withColumn(VERSION.toString(), DataTypes.TEXT).withColumn("\"projectVersionMetadataModel.key\"", DataTypes.TEXT).withColumn("classifier", DataTypes.TEXT).withColumn("optional", DataTypes.TEXT).withColumn("scope", DataTypes.TEXT).withColumn("systemPath", DataTypes.TEXT).withColumn("type", DataTypes.TEXT).withCompactStorage();
            session.execute(table.build());
            CreateIndex index = createIndex("groupIdIdx").ifNotExists().onTable(tableName).andColumn(GROUP_ID.toString());
            session.execute(index.build());
            index = createIndex("\"projectVersionMetadataModel_key\"").ifNotExists().onTable(tableName).andColumn("\"\"projectVersionMetadataModel.key\"\"");
            session.execute(index.build());
        }
    }
}
Also used : CreateIndex(com.datastax.oss.driver.api.querybuilder.schema.CreateIndex) ArrayList(java.util.ArrayList) CreateKeyspace(com.datastax.oss.driver.api.querybuilder.schema.CreateKeyspace) CreateTableWithOptions(com.datastax.oss.driver.api.querybuilder.schema.CreateTableWithOptions) CqlSession(com.datastax.oss.driver.api.core.CqlSession) PostConstruct(javax.annotation.PostConstruct)

Aggregations

CreateTableWithOptions (com.datastax.oss.driver.api.querybuilder.schema.CreateTableWithOptions)4 Configuration (org.janusgraph.diskstorage.configuration.Configuration)2 GraphDatabaseConfiguration.buildGraphConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.buildGraphConfiguration)2 Test (org.junit.Test)2 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 CreateIndex (com.datastax.oss.driver.api.querybuilder.schema.CreateIndex)1 CreateKeyspace (com.datastax.oss.driver.api.querybuilder.schema.CreateKeyspace)1 ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1