本文整理匯總了Java中org.kiji.schema.Kiji類的典型用法代碼示例。如果您正苦於以下問題:Java Kiji類的具體用法?Java Kiji怎麽用?Java Kiji使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Kiji類屬於org.kiji.schema包,在下文中一共展示了Kiji類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import org.kiji.schema.Kiji; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
mClusterURI = createTestHBaseURI();
Set<Kiji> kijis = Sets.newHashSet();
kijis.add(createTestKiji(mClusterURI));
kijis.add(createTestKiji(mClusterURI));
kijis.add(createTestKiji(mClusterURI));
installTables(kijis);
ImmutableSet.Builder<String> instances = ImmutableSet.builder();
for (Kiji kiji : kijis) {
instances.add(kiji.getURI().getInstance());
}
mInstanceNames = instances.build();
mKijiClient = new ManagedKijiClient(mClusterURI);
mKijiClient.start();
}
示例2: testCloseInstance
import org.kiji.schema.Kiji; //導入依賴的package包/類
@Test
public void testCloseInstance() throws Exception {
final String instanceName = mKiji.getURI().getInstance();
final Kiji kiji = mKijiClient.getKiji(instanceName);
Assert.assertEquals(ImmutableList.of(TABLE_NAME), kiji.getTableNames());
Assert.assertEquals(ImmutableSet.of(instanceName), mKijiClient.getInstances());
mCloseTask.execute(
ImmutableMultimap.of(CloseTask.INSTANCE_KEY, instanceName),
new PrintWriter(System.out));
// Kiji should be closed at this point
try {
kiji.getTableNames();
Assert.fail("A call to a Kiji method succeeded when it should have failed.");
} catch (IllegalStateException e) {
Assert.assertTrue(e.getMessage().contains("Cannot get table names in Kiji instance"));
}
}
示例3: testCloseTable
import org.kiji.schema.Kiji; //導入依賴的package包/類
@Test
public void testCloseTable() throws Exception {
final String instanceName = mKiji.getURI().getInstance();
final Kiji kiji = mKijiClient.getKiji(instanceName);
final KijiTable table = mKijiClient.getKijiTable(instanceName, TABLE_NAME);
table.retain().release(); // Will throw if closed
mCloseTask.execute(
ImmutableMultimap.of(
CloseTask.INSTANCE_KEY, instanceName, CloseTask.TABLE_KEY, TABLE_NAME),
new PrintWriter(System.out));
// Kiji should still be open
Assert.assertEquals(ImmutableList.of(TABLE_NAME), kiji.getTableNames());
// table should be closed at this point
try {
table.retain().release(); // Will throw
} catch (IllegalStateException e) {
return; // good
}
Assert.fail();
}
示例4: main
import org.kiji.schema.Kiji; //導入依賴的package包/類
/**
* Main. Pass in the instance to create the users table in.
*
* @param args instance to create user table in.
* @throws Exception if there is an exception.
*/
public static void main(String[] args) throws Exception {
final String userTableInstanceURI;
if (args.length == 0) {
userTableInstanceURI = DEFAULT_INSTANCE;
} else {
userTableInstanceURI = args[0];
}
final KijiURI kijiURI = KijiURI.newBuilder(userTableInstanceURI).build();
final Kiji kiji = Kiji.Factory.open(kijiURI);
// Create table.
kiji.createTable(
KijiTableLayout
.createFromEffectiveJsonResource(USER_TABLE_LAYOUT)
.getDesc());
final KijiTable userTable = kiji.openTable(USER_TABLE_NAME);
// Generate data.
final RandomDataGenerator gen = new RandomDataGenerator();
gen.generateData(USER_ID_MAX, userTable);
userTable.release();
kiji.release();
}
示例5: getInstanceMetadata
import org.kiji.schema.Kiji; //導入依賴的package包/類
/**
* GETs a list of instances that are available.
* @param instance is the instance whose metadata is being requested.
* @return the metadata about the instance.
*/
@GET
@Timed
@ApiStability.Experimental
public MetadataBackup getInstanceMetadata(@PathParam(INSTANCE_PARAMETER) String instance) {
Kiji kiji = mKijiClient.getKiji(instance);
try {
MetadataBackup backup = MetadataBackup.newBuilder()
.setLayoutVersion(kiji.getSystemTable().getDataVersion().toString())
.setSystemTable(kiji.getSystemTable().toBackup())
.setSchemaTable(kiji.getSchemaTable().toBackup())
.setMetaTable(kiji.getMetaTable().toBackup()).build();
return backup;
} catch (Exception e) {
throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
}
}
示例6: getTables
import org.kiji.schema.Kiji; //導入依賴的package包/類
/**
* GETs a list of tables in the specified instance.
*
* @param instance to list the contained tables.
* @return a map of tables to their respective resource URIs for easier future access.
*/
@GET
@Timed
@ApiStability.Evolving
public List<GenericResourceRepresentation> getTables(
@PathParam(INSTANCE_PARAMETER) String instance) {
List<GenericResourceRepresentation> tables = Lists.newArrayList();
Kiji kiji = mKijiClient.getKiji(instance);
try {
for (String table : kiji.getTableNames()) {
String tableUri = TABLE_PATH.replace("{" + TABLE_PARAMETER + "}", table)
.replace("{" + INSTANCE_PARAMETER + "}", instance);
tables.add(new GenericResourceRepresentation(table, tableUri));
}
} catch (IOException e) {
throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
}
return tables;
}
示例7: setUpResources
import org.kiji.schema.Kiji; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected void setUpResources() throws Exception {
mDelegate.setupKijiTest();
KijiURI clusterURI = mDelegate.createTestHBaseURI();
Kiji kiji1 = mDelegate.createTestKiji(clusterURI);
Kiji kiji2 = mDelegate.createTestKiji(clusterURI);
mInstances = Sets.newHashSet(kiji1.getURI().getInstance(), kiji2.getURI().getInstance());
KijiRESTService.registerSerializers(this.getObjectMapperFactory());
mClient = new ManagedKijiClient(clusterURI, ManagedKijiClient.DEFAULT_TIMEOUT, mInstances);
mClient.start();
mNullInstanceClient = new ManagedKijiClient(clusterURI,
ManagedKijiClient.DEFAULT_TIMEOUT,
null);
mNullInstanceClient.start();
addResource(new InstanceResource(mNullInstanceClient));
addResource(new InstancesResource(mClient));
}
示例8: KijiEntitiyManager
import org.kiji.schema.Kiji; //導入依賴的package包/類
private KijiEntitiyManager( String kijiInstance, String kijiCluster ) {
log.info("[KijiEntitiyManager]starting");
ClassLoader ctxCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(Kiji.class.getClassLoader());
try {
kiji = Kiji.Factory.open(KijiURI.newBuilder(kijiCluster).withInstanceName(kijiInstance).build());
log.info("[KijiEntitiyManager]connection open: " + kiji.getURI());
} catch (IOException e) {
log.error("[KijiEntitiyManager]Fail to open Kiji instance", e);
throw new KijiException(e);
} finally {
Thread.currentThread().setContextClassLoader(ctxCl);
}
}
示例9: setUp
import org.kiji.schema.Kiji; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
mConf = createConfiguration();
mFS = FileSystem.get(mConf);
mBulkImportInputPath = makeRandomPath("bulk-import-input");
writeTestResource(mBulkImportInputPath, "import-data/ddlshell-csv-import-input.txt");
mKijiURI = getKijiURI();
mKiji = Kiji.Factory.open(mKijiURI, mConf);
final KijiTableLayout layout = KijiTableLayout.newLayout(KijiMRTestLayouts.getTestLayout());
mKiji.createTable("test", layout);
mOutputTable = mKiji.openTable("test");
}
示例10: setUp
import org.kiji.schema.Kiji; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
mConf = createConfiguration();
mFS = FileSystem.get(mConf);
mBulkImportInputPath = makeRandomPath("bulk-import-input");
writeTestResource(mBulkImportInputPath, BulkImporterTestUtils.TIMESTAMP_CSV_IMPORT_DATA);
mImportDescriptorPath = makeRandomPath("import-descriptor");
writeTestResource(mImportDescriptorPath, BulkImporterTestUtils.FOO_TIMESTAMP_IMPORT_DESCRIPTOR);
mKiji = Kiji.Factory.open(getKijiURI(), mConf);
final KijiTableLayout layout = KijiTableLayout.newLayout(KijiMRTestLayouts.getTestLayout());
mKiji.createTable("test", layout);
mOutputTable = mKiji.openTable("test");
}
示例11: getKiji
import org.kiji.schema.Kiji; //導入依賴的package包/類
/** {@inheritDoc} */
@Override
public Kiji getKiji(String instance) {
final State state = mState.get();
Preconditions.checkState(state == State.STARTED,
"Can not get a Kiji while in state %s.", state);
return getInstanceCache(instance).getKiji();
}
示例12: installTables
import org.kiji.schema.Kiji; //導入依賴的package包/類
/**
* Install tables to the supplied Kiji instances.
*
* @param kijis to have tables installed in.
*/
private static void installTables(Set<Kiji> kijis) throws IOException {
TableLayoutDesc layout = KijiTableLayouts.getLayout("org/kiji/rest/layouts/sample_table.json");
for (Kiji kiji : kijis) {
InstanceBuilder builder = new InstanceBuilder(kiji);
for (String table : INSTANCE_TABLES) {
layout.setName(table);
builder.withTable(layout);
}
builder.build();
}
}
示例13: testShouldAllowAccessToVisibleInstancesOnly
import org.kiji.schema.Kiji; //導入依賴的package包/類
@Test
public void testShouldAllowAccessToVisibleInstancesOnly() throws Exception {
KijiURI clusterURI = createTestHBaseURI();
Set<Kiji> kijis = Sets.newHashSet();
// Create two instances with arbitrary names.
kijis.add(createTestKiji(clusterURI));
kijis.add(createTestKiji(clusterURI));
installTables(kijis);
Set<String> visibleInstances = Sets.newHashSet();
ImmutableSet.Builder<String> instances = ImmutableSet.builder();
for (Kiji kiji : kijis) {
instances.add(kiji.getURI().getInstance());
}
final ImmutableSet<String> instanceNames = instances.build();
// Select only the first instance to be visible.
visibleInstances.add(instanceNames.iterator().next());
ManagedKijiClient kijiClient = new ManagedKijiClient(
clusterURI,
ManagedKijiClient.DEFAULT_TIMEOUT,
visibleInstances);
kijiClient.start();
try {
assertEquals(1, kijiClient.getInstances().size());
} finally {
kijiClient.stop();
}
}
示例14: testShouldRefreshInstances
import org.kiji.schema.Kiji; //導入依賴的package包/類
@Test
public void testShouldRefreshInstances() throws Exception {
Kiji kiji = createTestKiji(mClusterURI);
String instance = kiji.getURI().getInstance();
Thread.sleep(50); // Give the ZK callback a chance to trigger
assertTrue(mKijiClient.getInstances().contains(instance));
deleteTestKiji(kiji);
Thread.sleep(50); // Give the ZK callback a chance to trigger
assertFalse(mKijiClient.getInstances().contains(instance));
}
示例15: getTable
import org.kiji.schema.Kiji; //導入依賴的package包/類
/**
* GETs the layout of the specified table.
*
* @param instance in which the table resides.
* @param table to get the layout for.
* @return the layout of the specified table
*/
@GET
@Timed
@ApiStability.Evolving
public TableLayoutDesc getTable(@PathParam(INSTANCE_PARAMETER) String instance,
@PathParam(TABLE_PARAMETER) String table) {
final Kiji kiji = mKijiClient.getKiji(instance);
TableLayoutDesc layout = null;
try {
layout = kiji.getMetaTable().getTableLayout(table).getDesc();
} catch (IOException e) {
throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
}
return layout;
}