本文整理汇总了Java中org.apache.accumulo.core.client.Connector类的典型用法代码示例。如果您正苦于以下问题:Java Connector类的具体用法?Java Connector怎么用?Java Connector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Connector类属于org.apache.accumulo.core.client包,在下文中一共展示了Connector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearTablesResetConf
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
@Before
public void clearTablesResetConf() throws Exception {
Connector con = mac.getConnector(MAC_ROOT_USER, MAC_ROOT_PASSWORD);
con.tableOperations().list().forEach(t -> {
if (t.startsWith("qonduit")) {
try {
con.tableOperations().delete(t);
} catch (Exception e) {
}
}
});
// Reset configuration
conf = TestConfiguration.createMinimalConfigurationForTest();
conf.getAccumulo().setInstanceName(mac.getInstanceName());
conf.getAccumulo().setZookeepers(mac.getZooKeepers());
conf.getSecurity().getSsl().setUseOpenssl(false);
conf.getSecurity().getSsl().setUseGeneratedKeypair(true);
}
示例2: SignedBatchWriter
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
/**
* Create an signed batch tableWriter.
*
* @param connector
* The connector for the Accumulo instance.
* @param tableName
* Name of the table to write to.
* @param batchConfig
* Configuration for a {@link BatchWriter}.
* @param signatureConfig
* Configuration for the signatures.
* @param keys
* Container with the keys to use for signatures.
*/
public SignedBatchWriter(Connector connector, String tableName, BatchWriterConfig batchConfig, SignatureConfig signatureConfig, SignatureKeyContainer keys)
throws TableNotFoundException {
checkArgument(connector != null, "connector is null");
checkArgument(tableName != null, "tableName is null");
checkArgument(signatureConfig != null, "signatureConfig is null");
checkArgument(keys != null, "keys is null");
this.tableWriter = connector.createBatchWriter(tableName, batchConfig);
this.signer = new EntrySigner(signatureConfig, keys);
this.signatureConfig = signatureConfig;
if (signatureConfig.destination == SignatureConfig.Destination.SEPARATE_TABLE) {
this.signatureTableWriter = connector.createBatchWriter(signatureConfig.destinationTable, batchConfig);
} else {
this.signatureTableWriter = null;
}
}
示例3: SignedScanner
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
/**
* Create an signed scanner.
*
* @param connector
* The connector for the Accumulo instance.
* @param tableName
* Name of the table to write to.
* @param authorizations
* The authorizations this user has for querying Accumulo.
* @param signatureConfig
* Configuration for the verification.
* @param keys
* Container with the keys to use for signatures.
*/
public SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys)
throws TableNotFoundException {
checkArgument(connector != null, "connection is null");
checkArgument(tableName != null, "tableName is null");
checkArgument(authorizations != null, "authorizations is null");
checkArgument(signatureConfig != null, "config is null");
checkArgument(keys != null, "keys is null");
this.valueScanner = connector.createScanner(tableName, authorizations);
this.verifier = new EntrySigner(signatureConfig, keys);
if (signatureConfig.destination == SignatureConfig.Destination.SEPARATE_TABLE) {
this.signatureScanner = connector.createScanner(signatureConfig.destinationTable, authorizations);
} else {
this.signatureScanner = null;
}
}
示例4: SignedBatchScanner
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
/**
* Create an encrypted batch scanner.
*
* @param connector
* The connector for the Accumulo instance.
* @param tableName
* Name of the table to write to.
* @param authorizations
* The authorizations this user has for querying Accumulo.
* @param numQueryThreads
* Maximimum number of query threads to use for this scanner.
* @param signatureConfig
* Configuration for the decryption.
* @param keys
* Container with the keys to use for decryption.
*/
public SignedBatchScanner(Connector connector, String tableName, Authorizations authorizations, int numQueryThreads, SignatureConfig signatureConfig,
SignatureKeyContainer keys) throws TableNotFoundException {
checkArgument(connector != null, "connection is null");
checkArgument(tableName != null, "tableName is null");
checkArgument(authorizations != null, "authorizations is null");
checkArgument(signatureConfig != null, "config is null");
checkArgument(keys != null, "keys is null");
this.valueScanner = connector.createBatchScanner(tableName, authorizations, numQueryThreads);
this.verifier = new EntrySigner(signatureConfig, keys);
if (signatureConfig.destination == SignatureConfig.Destination.SEPARATE_TABLE) {
this.signatureScanner = connector.createBatchScanner(signatureConfig.destinationTable, authorizations, numQueryThreads);
} else {
this.signatureScanner = null;
}
}
示例5: main
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
try (ConfigurableApplicationContext ctx = new SpringApplicationBuilder(SpringBootstrap.class)
.bannerMode(Mode.OFF).web(false).run(args)) {
Configuration conf = ctx.getBean(Configuration.class);
final BaseConfiguration apacheConf = new BaseConfiguration();
Configuration.Accumulo accumuloConf = conf.getAccumulo();
apacheConf.setProperty("instance.name", accumuloConf.getInstanceName());
apacheConf.setProperty("instance.zookeeper.host", accumuloConf.getZookeepers());
final ClientConfiguration aconf = new ClientConfiguration(Collections.singletonList(apacheConf));
final Instance instance = new ZooKeeperInstance(aconf);
Connector con = instance.getConnector(accumuloConf.getUsername(),
new PasswordToken(accumuloConf.getPassword()));
Scanner s = con.createScanner(conf.getMetaTable(),
con.securityOperations().getUserAuthorizations(con.whoami()));
try {
s.setRange(new Range(Meta.METRIC_PREFIX, true, Meta.TAG_PREFIX, false));
for (Entry<Key, Value> e : s) {
System.out.println(e.getKey().getRow().toString().substring(Meta.METRIC_PREFIX.length()));
}
} finally {
s.close();
}
}
}
示例6: clearTablesResetConf
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
@Before
public void clearTablesResetConf() throws Exception {
Connector con = mac.getConnector(MAC_ROOT_USER, MAC_ROOT_PASSWORD);
con.tableOperations().list().forEach(t -> {
if (t.startsWith("timely")) {
try {
con.tableOperations().delete(t);
} catch (Exception e) {
}
}
});
// Reset configuration
conf = TestConfiguration.createMinimalConfigurationForTest();
conf.getAccumulo().setInstanceName(mac.getInstanceName());
conf.getAccumulo().setZookeepers(mac.getZooKeepers());
conf.getSecurity().getSsl().setUseOpenssl(false);
conf.getSecurity().getSsl().setUseGeneratedKeypair(true);
conf.getWebsocket().setFlushIntervalSeconds(TestConfiguration.WAIT_SECONDS);
HashMap<String, Integer> ageOffSettings = new HashMap<>();
ageOffSettings.put(MetricAgeOffIterator.DEFAULT_AGEOFF_KEY, 7);
conf.setMetricAgeOffDays(ageOffSettings);
}
示例7: main
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(FileDataIngest.class.getName(), args, bwOpts);
Connector conn = opts.getConnector();
if (!conn.tableOperations().exists(opts.getTableName())) {
conn.tableOperations().create(opts.getTableName());
conn.tableOperations().attachIterator(opts.getTableName(), new IteratorSetting(1, ChunkCombiner.class));
}
BatchWriter bw = conn.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig());
FileDataIngest fdi = new FileDataIngest(opts.chunkSize, opts.visibility);
for (String filename : opts.files) {
fdi.insertFileData(filename, bw);
}
bw.close();
//TODO
//opts.stopTracing();
}
示例8: main
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, MutationsRejectedException, TableExistsException,
TableNotFoundException {
ClientOnRequiredTable opts = new ClientOnRequiredTable();
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(InsertWithBatchWriter.class.getName(), args, bwOpts);
Connector connector = opts.getConnector();
MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(bwOpts.getBatchWriterConfig());
if (!connector.tableOperations().exists(opts.getTableName()))
connector.tableOperations().create(opts.getTableName());
BatchWriter bw = mtbw.getBatchWriter(opts.getTableName());
Text colf = new Text("colfam");
System.out.println("writing ...");
for (int i = 0; i < 10000; i++) {
Mutation m = new Mutation(new Text(String.format("row_%d", i)));
for (int j = 0; j < 5; j++) {
m.put(colf, new Text(String.format("colqual_%d", j)), new Value((String.format("value_%d_%d", i, j)).getBytes()));
}
bw.addMutation(m);
if (i % 100 == 0)
System.out.println(i);
}
mtbw.close();
}
示例9: main
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
/**
* Writes a specified number of entries to Accumulo using a {@link BatchWriter}. The rows of the entries will be sequential starting at a specified number.
* The column families will be "foo" and column qualifiers will be "1". The values will be random byte arrays of a specified size.
*/
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException {
Opts opts = new Opts();
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(SequentialBatchWriter.class.getName(), args, bwOpts);
Connector connector = opts.getConnector();
BatchWriter bw = connector.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig());
long end = opts.start + opts.num;
for (long i = opts.start; i < end; i++) {
Mutation m = RandomBatchWriter.createMutation(i, opts.valueSize, opts.vis);
bw.addMutation(m);
}
bw.close();
}
示例10: main
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
BatchScannerOpts bsOpts = new BatchScannerOpts();
opts.parseArgs(Query.class.getName(), args, bsOpts);
Connector conn = opts.getConnector();
BatchScanner bs = conn.createBatchScanner(opts.getTableName(), opts.auths, bsOpts.scanThreads);
bs.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS);
if (opts.useSample) {
SamplerConfiguration samplerConfig = conn.tableOperations().getSamplerConfiguration(opts.getTableName());
CutoffIntersectingIterator.validateSamplerConfig(conn.tableOperations().getSamplerConfiguration(opts.getTableName()));
bs.setSamplerConfiguration(samplerConfig);
}
for (String entry : query(bs, opts.terms, opts.sampleCutoff))
System.out.println(" " + entry);
bs.close();
}
示例11: main
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
ScannerOpts scanOpts = new ScannerOpts();
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(Reverse.class.getName(), args, scanOpts, bwOpts);
Connector conn = opts.getConnector();
Scanner scanner = conn.createScanner(opts.shardTable, opts.auths);
scanner.setBatchSize(scanOpts.scanBatchSize);
BatchWriter bw = conn.createBatchWriter(opts.doc2TermTable, bwOpts.getBatchWriterConfig());
for (Entry<Key,Value> entry : scanner) {
Key key = entry.getKey();
Mutation m = new Mutation(key.getColumnQualifier());
m.put(key.getColumnFamily(), new Text(), new Value(new byte[0]));
bw.addMutation(m);
}
bw.close();
}
示例12: content
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
public Results content(String query, String auths) {
log.info("Content query: " + query);
Connector connector = null;
if (null == instanceName || null == zooKeepers || null == username || null == password)
throw new EJBException("Required parameters not set. [instanceName = " + this.instanceName + ", zookeepers = " + this.zooKeepers + ", username = "
+ this.username + (password==null?", password = null":"") + "]. Check values in ejb-jar.xml");
Instance instance = new ZooKeeperInstance(this.instanceName, this.zooKeepers);
try {
log.info("Connecting to [instanceName = " + this.instanceName + ", zookeepers = " + this.zooKeepers + ", username = " + this.username + "].");
connector = instance.getConnector(this.username, new PasswordToken(this.password.getBytes()));
} catch (Exception e) {
throw new EJBException("Error getting connector from instance", e);
}
// Create list of auths
List<String> authorizations = new ArrayList<String>();
if (auths != null && auths.length() > 0)
for (String a : auths.split(","))
authorizations.add(a);
ContentLogic table = new ContentLogic();
table.setTableName(tableName);
return table.runQuery(connector, query, authorizations);
}
示例13: loadBulkFiles
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
private int loadBulkFiles() throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException
{
Configuration conf = getConf();
Connector connector = WikipediaConfiguration.getConnector(conf);
FileSystem fs = FileSystem.get(conf);
String directory = WikipediaConfiguration.bulkIngestDir(conf);
String failureDirectory = WikipediaConfiguration.bulkIngestFailureDir(conf);
for(FileStatus status: fs.listStatus(new Path(directory)))
{
if(status.isDir() == false)
continue;
Path dir = status.getPath();
Path failPath = new Path(failureDirectory+"/"+dir.getName());
fs.mkdirs(failPath);
connector.tableOperations().importDirectory(dir.getName(), dir.toString(), failPath.toString(), true);
}
return 0;
}
示例14: compactTransient
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
/**
* Compact all transient regions that were registered using {@link TransientRegistry}
*/
public static void compactTransient(FluoConfiguration fluoConfig) throws Exception {
Connector conn = getConnector(fluoConfig);
try (FluoClient client = FluoFactory.newClient(fluoConfig)) {
SimpleConfiguration appConfig = client.getAppConfiguration();
TransientRegistry transientRegistry = new TransientRegistry(appConfig);
List<RowRange> ranges = transientRegistry.getTransientRanges();
for (RowRange r : ranges) {
long t1 = System.currentTimeMillis();
conn.tableOperations().compact(fluoConfig.getAccumuloTable(),
new Text(r.getStart().toArray()), new Text(r.getEnd().toArray()), true, true);
long t2 = System.currentTimeMillis();
logger.info("Compacted {} in {}ms", r, (t2 - t1));
}
}
}
示例15: removeIterators
import org.apache.accumulo.core.client.Connector; //导入依赖的package包/类
private void removeIterators(
final String tablename,
final Connector connector )
throws AccumuloSecurityException,
AccumuloException,
TableNotFoundException {
connector.tableOperations().removeIterator(
tablename,
new IteratorSetting(
FeatureCollectionDataAdapter.ARRAY_TO_ELEMENTS_PRIORITY,
ArrayToElementsIterator.class).getName(),
EnumSet.of(IteratorScope.scan));
connector.tableOperations().removeIterator(
tablename,
new IteratorSetting(
FeatureCollectionDataAdapter.ELEMENTS_TO_ARRAY_PRIORITY,
ElementsToArrayIterator.class).getName(),
EnumSet.of(IteratorScope.scan));
}