use of com.datastax.oss.driver.api.querybuilder.schema.CreateIndex in project automatiko-engine by automatiko-io.
the class CassandraProcessInstances method createTable.
protected void createTable() {
if (config.createKeyspace().orElse(true)) {
CreateKeyspace createKs = createKeyspace(config.keyspace().orElse("automatiko")).ifNotExists().withSimpleStrategy(1);
cqlSession.execute(createKs.build());
}
CreateTable createTable = SchemaBuilder.createTable(config.keyspace().orElse("automatiko"), tableName).ifNotExists().withPartitionKey(INSTANCE_ID_FIELD, DataTypes.TEXT).withColumn(STATUS_FIELD, DataTypes.INT).withColumn(CONTENT_FIELD, DataTypes.BLOB).withColumn(TAGS_FIELD, DataTypes.setOf(DataTypes.TEXT)).withColumn(VERSION_FIELD, DataTypes.BIGINT);
cqlSession.execute(createTable.build());
CreateIndex index = SchemaBuilder.createIndex(tableName + "_STATUS_IDX").ifNotExists().onTable(config.keyspace().orElse("automatiko"), tableName).andColumn(STATUS_FIELD);
cqlSession.execute(index.build());
}
use of com.datastax.oss.driver.api.querybuilder.schema.CreateIndex in project automatiko-engine by automatiko-io.
the class CassandraJobService method createTable.
protected void createTable() {
if (config.createKeyspace().orElse(true)) {
CreateKeyspace createKs = createKeyspace(config.keyspace().orElse("automatiko")).ifNotExists().withSimpleStrategy(1);
cqlSession.execute(createKs.build());
}
CreateTable createTable = SchemaBuilder.createTable(config.keyspace().orElse("automatiko"), tableName).ifNotExists().withPartitionKey(INSTANCE_ID_FIELD, DataTypes.TEXT).withColumn(FIRE_AT_FIELD, DataTypes.BIGINT).withColumn(OWNER_INSTANCE_ID_FIELD, DataTypes.TEXT).withColumn(OWNER_DEF_ID_FIELD, DataTypes.TEXT).withColumn(TRIGGER_TYPE_FIELD, DataTypes.TEXT).withColumn(STATUS_FIELD, DataTypes.TEXT).withColumn(FIRE_LIMIT_FIELD, DataTypes.INT).withColumn(REPEAT_INTERVAL_FIELD, DataTypes.BIGINT).withColumn(EXPRESSION_FIELD, DataTypes.TEXT);
cqlSession.execute(createTable.build());
CreateIndex index = SchemaBuilder.createIndex(tableName + "_IDX").ifNotExists().onTable(config.keyspace().orElse("automatiko"), tableName).andColumn(FIRE_AT_FIELD);
cqlSession.execute(index.build());
}
use of com.datastax.oss.driver.api.querybuilder.schema.CreateIndex 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());
}
}
}
Aggregations