/** * A generic helper function to create a table with default test options. */ public static KuduTable createDefaultTable(KuduClient client, String tableName) throws KuduException { return client.createTable(tableName, getBasicSchema(), getBasicCreateTableOptions()); }
@Before public void setUp() throws Exception { CreateTableOptions options = getBasicCreateTableOptions().setNumReplicas(1); table = harness.getClient().createTable(TABLE_NAME, getBasicSchema(), options); }
@Before public void setUp() throws Exception { String runtimeProp = System.getProperty(RUNTIME_PROPERTY_NAME); runtimeInSeconds = runtimeProp == null ? DEFAULT_RUNTIME_SECONDS : Long.parseLong(runtimeProp); if (runtimeInSeconds < TEST_MIN_RUNTIME_SECONDS || runtimeInSeconds > TEST_TIMEOUT_SECONDS) { Assert.fail("This test needs to run more than " + TEST_MIN_RUNTIME_SECONDS + " seconds" + " and less than " + TEST_TIMEOUT_SECONDS + " seconds"); } LOG.info ("Test running for {} seconds", runtimeInSeconds); // Client we're using has low tolerance for read timeouts but a // higher overall operation timeout. localAsyncClient = new AsyncKuduClient.AsyncKuduClientBuilder(harness.getMasterAddressesAsString()) .defaultSocketReadTimeoutMs(500) .build(); localClient = new KuduClient(localAsyncClient); CreateTableOptions builder = new CreateTableOptions().setNumReplicas(3); builder.setRangePartitionColumns(ImmutableList.of("key")); table = localClient.createTable(TABLE_NAME, getBasicSchema(), builder); }
@Before public void setUp() throws Exception { CreateTableOptions builder = getBasicCreateTableOptions(); harness.getClient().createTable(TABLE_NAME, getBasicSchema(), builder); table = harness.getClient().openTable(TABLE_NAME); }
KuduTable table = newClient.createTable(TABLE_NAME, getBasicSchema(), getBasicCreateTableOptions()); KuduSession session = newClient.newSession();
String tableName = TestMultipleLeaderFailover.class.getName() + "-" + System.currentTimeMillis(); harness.getClient().createTable(tableName, getBasicSchema(), builder);
harness.getClient().createTable(tableName, getBasicSchema(), getBasicCreateTableOptions());
/** * Creates table options with non-covering range partitioning for a table with * the basic schema. Range partition key ranges fall between the following values: * * [ 0, 50) * [ 50, 100) * [200, 300) */ public static CreateTableOptions getBasicTableOptionsWithNonCoveredRange() { Schema schema = getBasicSchema(); CreateTableOptions option = new CreateTableOptions(); option.setRangePartitionColumns(ImmutableList.of("key")); PartialRow aLowerBound = schema.newPartialRow(); aLowerBound.addInt("key", 0); PartialRow aUpperBound = schema.newPartialRow(); aUpperBound.addInt("key", 100); option.addRangePartition(aLowerBound, aUpperBound); PartialRow bLowerBound = schema.newPartialRow(); bLowerBound.addInt("key", 200); PartialRow bUpperBound = schema.newPartialRow(); bUpperBound.addInt("key", 300); option.addRangePartition(bLowerBound, bUpperBound); PartialRow split = schema.newPartialRow(); split.addInt("key", 50); option.addSplitRow(split); return option; }
KuduTable table = client.createTable(tableName, getBasicSchema(), new CreateTableOptions().setRangePartitionColumns( new ArrayList<String>()));
public static KuduTable createFourTabletsTableWithNineRows(AsyncKuduClient client, String tableName, final long timeoutMs) throws Exception { final int[] KEYS = new int[] { 10, 20, 30 }; final Schema basicSchema = getBasicSchema(); CreateTableOptions builder = getBasicCreateTableOptions(); for (int i : KEYS) { PartialRow splitRow = basicSchema.newPartialRow(); splitRow.addInt(0, i); builder.addSplitRow(splitRow); } KuduTable table = client.syncClient().createTable(tableName, basicSchema, builder); AsyncKuduSession session = client.newSession(); // create a table with on empty tablet and 3 tablets of 3 rows each for (int key1 : KEYS) { for (int key2 = 1; key2 <= 3; key2++) { Insert insert = table.newInsert(); PartialRow row = insert.getRow(); row.addInt(0, key1 + key2); row.addInt(1, key1); row.addInt(2, key2); row.addString(3, "a string"); row.addBoolean(4, true); session.apply(insert).join(timeoutMs); } } session.close().join(timeoutMs); return table; }
harness.getClient().createTable(TABLE_NAME, getBasicSchema(), getBasicCreateTableOptions()); KuduTable table = lowTimeoutsClient.openTable(TABLE_NAME);