本文整理汇总了Java中org.apache.cassandra.SchemaLoader类的典型用法代码示例。如果您正苦于以下问题:Java SchemaLoader类的具体用法?Java SchemaLoader怎么用?Java SchemaLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SchemaLoader类属于org.apache.cassandra包,在下文中一共展示了SchemaLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRegularMode
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@Test
public void testRegularMode() throws ConfigurationException
{
SchemaLoader.mkdirs();
SchemaLoader.cleanup();
StorageService.instance.initServer(0);
for (String path : DatabaseDescriptor.getAllDataFileLocations())
{
// verify that storage directories are there.
assertTrue(new File(path).exists());
}
// a proper test would be to call decommission here, but decommission() mixes both shutdown and datatransfer
// calls. This test is only interested in the shutdown-related items which a properly handled by just
// stopping the client.
//StorageService.instance.decommission();
StorageService.instance.stopClient();
}
示例2: testRegularMode
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@Test
public void testRegularMode() throws IOException, InterruptedException, ConfigurationException
{
SchemaLoader.mkdirs();
SchemaLoader.cleanup();
StorageService.instance.initServer(0);
for (String path : DatabaseDescriptor.getAllDataFileLocations())
{
// verify that storage directories are there.
assertTrue(new File(path).exists());
}
// a proper test would be to call decommission here, but decommission() mixes both shutdown and datatransfer
// calls. This test is only interested in the shutdown-related items which a properly handled by just
// stopping the client.
//StorageService.instance.decommission();
StorageService.instance.stopClient();
}
示例3: testWriteReadCycle
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@Test
public void testWriteReadCycle() throws IOException
{
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE, KeyspaceParams.simple(1), SchemaLoader.standardCFMD(KEYSPACE, TABLE));
HintsDescriptor descriptor = new HintsDescriptor(UUID.randomUUID(), System.currentTimeMillis());
File directory = Files.createTempDirectory(null).toFile();
try
{
testWriteReadCycle(directory, descriptor);
}
finally
{
directory.deleteOnExit();
}
}
示例4: initialize
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
static public void initialize() throws IOException
{
try (FileInputStream fis = new FileInputStream("CHANGES.txt"))
{
dataSource = ByteBuffer.allocateDirect((int) fis.getChannel().size());
while (dataSource.hasRemaining())
{
fis.getChannel().read(dataSource);
}
dataSource.flip();
}
SchemaLoader.loadSchema();
SchemaLoader.schemaDefinition(""); // leave def. blank to maintain old behaviour
}
示例5: testNonTextComparator
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@Test // test for CASSANDRA-8178
public void testNonTextComparator() throws Throwable
{
ColumnDef column = new ColumnDef();
column.setName(bytes(42))
.setValidation_class(UTF8Type.instance.toString());
CfDef cf = new CfDef("thriftcompat", "JdbcInteger");
cf.setColumn_type("Standard")
.setComparator_type(Int32Type.instance.toString())
.setDefault_validation_class(UTF8Type.instance.toString())
.setKey_validation_class(BytesType.instance.toString())
.setColumn_metadata(Collections.singletonList(column));
SchemaLoader.createKeyspace("thriftcompat", KeyspaceParams.simple(1), ThriftConversion.fromThrift(cf));
// the comparator is IntegerType, and there is a column named 42 with a UTF8Type validation type
execute("INSERT INTO \"thriftcompat\".\"JdbcInteger\" (key, \"42\") VALUES (0x00000001, 'abc')");
execute("UPDATE \"thriftcompat\".\"JdbcInteger\" SET \"42\" = 'abc' WHERE key = 0x00000001");
execute("DELETE \"42\" FROM \"thriftcompat\".\"JdbcInteger\" WHERE key = 0x00000000");
UntypedResultSet results = execute("SELECT key, \"42\" FROM \"thriftcompat\".\"JdbcInteger\"");
assertEquals(1, results.size());
UntypedResultSet.Row row = results.iterator().next();
assertEquals(ByteBufferUtil.bytes(1), row.getBytes("key"));
assertEquals("abc", row.getString("42"));
}
示例6: defineSchema
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
CFMetaData cfMetadata = CFMetaData.Builder.create(KEYSPACE1, CF_STANDARD)
.addPartitionKey("key", BytesType.instance)
.addClusteringColumn("col1", AsciiType.instance)
.addRegularColumn("c1", AsciiType.instance)
.addRegularColumn("c2", AsciiType.instance)
.addRegularColumn("one", AsciiType.instance)
.addRegularColumn("two", AsciiType.instance)
.build();
CFMetaData cfMetaData2 = CFMetaData.Builder.create(KEYSPACE1, CF_COLLECTION)
.addPartitionKey("k", ByteType.instance)
.addRegularColumn("m", MapType.getInstance(IntegerType.instance, IntegerType.instance, true))
.build();
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
cfMetadata, cfMetaData2);
}
示例7: defineSchema
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
new Random().nextBytes(entropy);
DatabaseDescriptor.setCommitLogCompression(new ParameterizedClass("LZ4Compressor", ImmutableMap.of()));
DatabaseDescriptor.setCommitLogSegmentSize(1);
DatabaseDescriptor.setCommitLogSync(CommitLogSync.periodic);
DatabaseDescriptor.setCommitLogSyncPeriod(10 * 1000);
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE1, STANDARD1, 0, AsciiType.instance, BytesType.instance),
SchemaLoader.standardCFMD(KEYSPACE1, STANDARD2, 0, AsciiType.instance, BytesType.instance));
CompactionManager.instance.disableAutoCompaction();
}
示例8: defineSchema
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
cfm = CFMetaData.Builder.create(KEYSPACE, TABLE)
.addPartitionKey("k", UTF8Type.instance)
.addStaticColumn("s", UTF8Type.instance)
.addClusteringColumn("i", IntegerType.instance)
.addRegularColumn("v", UTF8Type.instance)
.build();
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE, KeyspaceParams.simple(1), cfm);
cfm = Schema.instance.getCFMetaData(KEYSPACE, TABLE);
v = cfm.getColumnDefinition(new ColumnIdentifier("v", true));
s = cfm.getColumnDefinition(new ColumnIdentifier("s", true));
}
示例9: defineSchema
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2));
SchemaLoader.createKeyspace(KEYSPACE2,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE2, CF_STANDARD1));
SchemaLoader.createKeyspace(KEYSPACE_CACHED,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE_CACHED, CF_CACHED).caching(CachingParams.CACHE_EVERYTHING));
SchemaLoader.createKeyspace(KEYSPACE_CQL,
KeyspaceParams.simple(1),
CFMetaData.compile("CREATE TABLE " + CF_CQL + " ("
+ "k int PRIMARY KEY,"
+ "v1 text,"
+ "v2 int"
+ ")", KEYSPACE_CQL));
}
示例10: defineSchema
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
long seed = System.nanoTime();
//long seed = 754271160974509L; // CASSANDRA-9530: use this seed to reproduce compaction failures if reading empty rows
//long seed = 2080431860597L; // CASSANDRA-12359: use this seed to reproduce undetected corruptions
logger.info("Seed {}", seed);
random = new Random(seed);
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
makeTable(STANDARD_STCS).compaction(CompactionParams.DEFAULT),
makeTable(STANDARD_LCS).compaction(CompactionParams.lcs(Collections.emptyMap())));
maxValueSize = DatabaseDescriptor.getMaxValueSize();
DatabaseDescriptor.setMaxValueSize(1024 * 1024);
closeStdErr();
}
示例11: defineSchema
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
Map<String, String> compactionOptions = new HashMap<>();
compactionOptions.put("tombstone_compaction_interval", "1");
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
SchemaLoader.denseCFMD(KEYSPACE1, CF_DENSE1)
.compaction(CompactionParams.scts(compactionOptions)),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1)
.compaction(CompactionParams.scts(compactionOptions)),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD3),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD4),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPER1, AsciiType.instance),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPER5, AsciiType.instance),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPERGC, AsciiType.instance)
.gcGraceSeconds(0));
}
示例12: defineSchema
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws Exception
{
SchemaLoader.prepareServer();
StorageService.instance.initServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD),
CFMetaData.Builder.create(KEYSPACE1, CF_COUNTER, false, true, true)
.addPartitionKey("key", BytesType.instance)
.build(),
CFMetaData.Builder.create(KEYSPACE1, CF_STANDARDINT)
.addPartitionKey("key", AsciiType.instance)
.addClusteringColumn("cols", Int32Type.instance)
.addRegularColumn("val", BytesType.instance)
.build(),
SchemaLoader.compositeIndexCFMD(KEYSPACE1, CF_INDEX, true));
SchemaLoader.createKeyspace(KEYSPACE2,
KeyspaceParams.simple(1));
SchemaLoader.createKeyspace(KEYSPACE_CACHEKEY,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE_CACHEKEY, CF_STANDARD),
SchemaLoader.standardCFMD(KEYSPACE_CACHEKEY, CF_STANDARD2),
SchemaLoader.standardCFMD(KEYSPACE_CACHEKEY, CF_STANDARD3));
}
示例13: defineSchema
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
CompressionParams compressionParameters = CompressionParams.snappy(32768);
SchemaLoader.loadSchema();
SchemaLoader.createKeyspace(KEYSPACE,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE, CF).compression(compressionParameters),
SchemaLoader.standardCFMD(KEYSPACE, CF2).compression(compressionParameters),
SchemaLoader.standardCFMD(KEYSPACE, CF3),
SchemaLoader.standardCFMD(KEYSPACE, CF4),
SchemaLoader.standardCFMD(KEYSPACE, CORRUPT_CF),
SchemaLoader.standardCFMD(KEYSPACE, CORRUPT_CF2),
SchemaLoader.counterCFMD(KEYSPACE, COUNTER_CF).compression(compressionParameters),
SchemaLoader.counterCFMD(KEYSPACE, COUNTER_CF2).compression(compressionParameters),
SchemaLoader.counterCFMD(KEYSPACE, COUNTER_CF3),
SchemaLoader.counterCFMD(KEYSPACE, COUNTER_CF4),
SchemaLoader.counterCFMD(KEYSPACE, CORRUPTCOUNTER_CF),
SchemaLoader.counterCFMD(KEYSPACE, CORRUPTCOUNTER_CF2),
SchemaLoader.standardCFMD(KEYSPACE, CF_UUID, 0, UUIDType.instance));
}
示例14: defineSchema
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
if (FBUtilities.isWindows())
{
standardMode = DatabaseDescriptor.getDiskAccessMode();
indexMode = DatabaseDescriptor.getIndexAccessMode();
DatabaseDescriptor.setDiskAccessMode(Config.DiskAccessMode.standard);
DatabaseDescriptor.setIndexAccessMode(Config.DiskAccessMode.standard);
}
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE, CF),
SchemaLoader.standardCFMD(KEYSPACE, CF_SMALL_MAX_VALUE));
maxValueSize = DatabaseDescriptor.getMaxValueSize();
DatabaseDescriptor.setMaxValueSize(1024 * 1024); // set max value size to 1MB
}
示例15: setup
import org.apache.cassandra.SchemaLoader; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception
{
SchemaLoader.mkdirs();
SchemaLoader.cleanup();
Keyspace.setInitialized();
StorageService.instance.initServer(0);
}