本文整理汇总了Java中org.apache.accumulo.core.client.security.tokens.PasswordToken类的典型用法代码示例。如果您正苦于以下问题:Java PasswordToken类的具体用法?Java PasswordToken怎么用?Java PasswordToken使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PasswordToken类属于org.apache.accumulo.core.client.security.tokens包,在下文中一共展示了PasswordToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DataStore
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
public DataStore(Configuration conf) throws QonduitException {
try {
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 = instance
.getConnector(accumuloConf.getUsername(), new PasswordToken(accumuloConf.getPassword()));
} catch (Exception e) {
throw new QonduitException(HttpResponseStatus.INTERNAL_SERVER_ERROR.code(), "Error creating DataStoreImpl",
e.getMessage(), e);
}
}
示例2: main
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的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();
}
}
}
示例3: getHadoopOF
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
/**
* creates output format to write data from flink DataSet to accumulo
* @return
* @throws AccumuloSecurityException
*/
public HadoopOutputFormat getHadoopOF() throws AccumuloSecurityException, IOException {
if(job == null){
job = Job.getInstance(new Configuration(), jobName);
}
AccumuloOutputFormat.setConnectorInfo(job, accumuloUser, new PasswordToken(accumuloPassword));
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.withInstance(accumuloInstanceName);
clientConfig.withZkHosts(accumuloZookeeper);
AccumuloOutputFormat.setZooKeeperInstance(job, clientConfig);
AccumuloOutputFormat.setDefaultTableName(job, outTable);
AccumuloFileOutputFormat.setOutputPath(job,new Path("/tmp"));
HadoopOutputFormat<Text, Mutation> hadoopOF =
new HadoopOutputFormat<>(new AccumuloOutputFormat() , job);
return hadoopOF;
}
示例4: createBatchWriter
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
/**
* creates a batchwriter to write data to accumulo
*
* @param table to write data into
* @return a ready to user batch writer object
* @throws AccumuloSecurityException
* @throws AccumuloException
* @throws TableNotFoundException
*/
private BatchWriter createBatchWriter(String table) throws AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException {
final BatchWriterConfig bwConfig = new BatchWriterConfig();
// buffer max 100kb ( 100 * 1024 = 102400)
bwConfig.setMaxMemory(102400);
// buffer max 10 seconds
bwConfig.setMaxLatency(10, TimeUnit.SECONDS);
// ensure persistance
bwConfig.setDurability(Durability.SYNC);
// build the accumulo connector
Instance inst = new ZooKeeperInstance(cfg.accumuloInstanceName, cfg.accumuloZookeeper);
conn = inst.getConnector(cfg.accumuloUser, new PasswordToken(cfg.accumuloPassword));
Authorizations auths = new Authorizations(AccumuloIdentifiers.AUTHORIZATION.toString());
// create the table if not already existent
TableOperations tableOpts = conn.tableOperations();
try{
tableOpts.create(table);
} catch(Exception e) {}
// build and return the batchwriter
return conn.createBatchWriter(table, bwConfig);
}
示例5: createBatchWriter
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
/**
* creates a batchwriter to write data to accumulo
*
* @param table to write data into
* @return a ready to user batch writer object
* @throws AccumuloSecurityException
* @throws AccumuloException
* @throws TableNotFoundException
*/
private BatchWriter createBatchWriter(String table) throws AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException {
final BatchWriterConfig bwConfig = new BatchWriterConfig();
// buffer max 100kb ( 100 * 1024 = 102400)
bwConfig.setMaxMemory(102400);
// buffer max 10 seconds
bwConfig.setMaxLatency(10, TimeUnit.SECONDS);
// ensure persistance
bwConfig.setDurability(Durability.SYNC);
// build the accumulo connector
Instance inst = new ZooKeeperInstance(cfg.accumuloInstanceName, cfg.accumuloZookeeper);
conn = inst.getConnector(cfg.accumuloUser, new PasswordToken(cfg.accumuloPassword));
Authorizations auths = new Authorizations(AccumuloIdentifiers.AUTHORIZATION.toString());
// create the table if not already existent
TableOperations tableOpts = conn.tableOperations();
try{
tableOpts.create(table);
} catch(Exception e) {}
// build and return the batchwriter
return conn.createBatchWriter(table, bwConfig);
}
示例6: getClusterInfo
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
@Before
public void getClusterInfo() throws Exception {
c = getConnector();
String user = getAdminPrincipal();
String instance = c.getInstance().getInstanceName();
String keepers = c.getInstance().getZooKeepers();
AuthenticationToken token = getAdminToken();
if (token instanceof PasswordToken) {
String passwd = new String(((PasswordToken) getAdminToken()).getPassword(), UTF_8);
writeConnectionFile(getConnectionFile(), instance, keepers, user, passwd);
} else {
Assert.fail("Unknown token type: " + token);
}
fs = getCluster().getFileSystem();
dir = new Path(cluster.getTemporaryPath(), getClass().getName()).toString();
origAuths = c.securityOperations().getUserAuthorizations(user);
c.securityOperations().changeUserAuthorizations(user, new Authorizations(auths.split(",")));
}
示例7: testBulkIngest
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
@Test
public void testBulkIngest() throws Exception {
// TODO Figure out a way to run M/R with Kerberos
assumeTrue(getAdminToken() instanceof PasswordToken);
String tableName = getUniqueNames(1)[0];
FileSystem fs = getFileSystem();
Path p = new Path(dir, "tmp");
if (fs.exists(p)) {
fs.delete(p, true);
}
goodExec(GenerateTestData.class, "--start-row", "0", "--count", "10000", "--output", dir + "/tmp/input/data");
List<String> commonArgs = new ArrayList<>(Arrays.asList(new String[] {"-c", getConnectionFile(), "--table", tableName}));
List<String> args = new ArrayList<>(commonArgs);
goodExec(SetupTable.class, args.toArray(new String[0]));
args = new ArrayList<>(commonArgs);
args.addAll(Arrays.asList(new String[] {"--inputDir", dir + "/tmp/input", "--workDir", dir + "/tmp"}));
goodExec(BulkIngestExample.class, args.toArray(new String[0]));
args = new ArrayList<>(commonArgs);
args.addAll(Arrays.asList(new String[] {"--start-row", "0", "--count", "10000"}));
goodExec(VerifyIngest.class, args.toArray(new String[0]));
}
示例8: testTeraSortAndRead
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
@Test
public void testTeraSortAndRead() throws Exception {
// TODO Figure out a way to run M/R with Kerberos
assumeTrue(getAdminToken() instanceof PasswordToken);
String tableName = getUniqueNames(1)[0];
String[] args = new String[] {"--count", (1000 * 1000) + "", "-nk", "10", "-xk", "10", "-nv", "10", "-xv", "10", "-t", tableName, "-c", getConnectionFile(),
"--splits", "4"};
goodExec(TeraSortIngest.class, args);
Path output = new Path(dir, "tmp/nines");
if (fs.exists(output)) {
fs.delete(output, true);
}
args = new String[] {"-c", getConnectionFile(), "-t", tableName, "--rowRegex", ".*999.*", "--output", output.toString()};
goodExec(RegexExample.class, args);
args = new String[] {"-c", getConnectionFile(), "-t", tableName, "--column", "c:"};
goodExec(RowHash.class, args);
output = new Path(dir, "tmp/tableFile");
if (fs.exists(output)) {
fs.delete(output, true);
}
args = new String[] {"-c", getConnectionFile(), "-t", tableName, "--output", output.toString()};
goodExec(TableToFile.class, args);
}
示例9: testWordCount
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
@Test
public void testWordCount() throws Exception {
// TODO Figure out a way to run M/R with Kerberos
assumeTrue(getAdminToken() instanceof PasswordToken);
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
is = new IteratorSetting(10, SummingCombiner.class);
SummingCombiner.setColumns(is, Collections.singletonList(new IteratorSetting.Column(new Text("count"))));
SummingCombiner.setEncodingType(is, SummingCombiner.Type.STRING);
c.tableOperations().attachIterator(tableName, is);
Path readme = new Path(new Path(System.getProperty("user.dir")).getParent(), "README.md");
if (!new File(readme.toString()).exists()) {
log.info("Not running test: README.md does not exist)");
return;
}
fs.copyFromLocalFile(readme, new Path(dir + "/tmp/wc/README.md"));
String[] args;
args = new String[] {"-c", getConnectionFile(), "--input", dir + "/tmp/wc", "-t", tableName};
goodExec(WordCount.class, args);
}
示例10: content
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的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);
}
示例11: ExportTask
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
ExportTask(String instanceName, String zookeepers, String user, String password, String table)
throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
ZooKeeperInstance zki = new ZooKeeperInstance(
new ClientConfiguration().withInstance(instanceName).withZkHosts(zookeepers));
// TODO need to close batch writer
Connector conn = zki.getConnector(user, new PasswordToken(password));
try {
bw = conn.createBatchWriter(table, new BatchWriterConfig());
} catch (TableNotFoundException tnfe) {
try {
conn.tableOperations().create(table);
} catch (TableExistsException e) {
// nothing to do
}
bw = conn.createBatchWriter(table, new BatchWriterConfig());
}
}
示例12: setUp
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
dao = new AccumuloRyaDAO();
connector = new MockInstance().getConnector("", new PasswordToken(""));
dao.setConnector(connector);
conf = new AccumuloRdfConfiguration();
dao.setConf(conf);
dao.init();
store = new RdfCloudTripleStore();
store.setConf(conf);
store.setRyaDAO(dao);
inferenceEngine = new InferenceEngine();
inferenceEngine.setRyaDAO(dao);
store.setInferenceEngine(inferenceEngine);
inferenceEngine.refreshGraph();
store.initialize();
repository = new SailRepository(store);
conn = repository.getConnection();
}
示例13: init
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
@Before
public void init() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
mock = new MockInstance("accumulo");
PasswordToken pToken = new PasswordToken("pass".getBytes());
conn = mock.getConnector("user", pToken);
config = new BatchWriterConfig();
config.setMaxMemory(1000);
config.setMaxLatency(1000, TimeUnit.SECONDS);
config.setMaxWriteThreads(10);
if (conn.tableOperations().exists("rya_prospects")) {
conn.tableOperations().delete("rya_prospects");
}
if (conn.tableOperations().exists("rya_selectivity")) {
conn.tableOperations().delete("rya_selectivity");
}
arc = new AccumuloRdfConfiguration();
arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
arc.setMaxRangesForScanner(300);
}
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:RdfCloudTripleStoreSelectivityEvaluationStatisticsTest.java
示例14: init
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
@Before
public void init() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
mock = new MockInstance("accumulo");
PasswordToken pToken = new PasswordToken("pass".getBytes());
conn = mock.getConnector("user", pToken);
config = new BatchWriterConfig();
config.setMaxMemory(1000);
config.setMaxLatency(1000, TimeUnit.SECONDS);
config.setMaxWriteThreads(10);
if (conn.tableOperations().exists("rya_prospects")) {
conn.tableOperations().delete("rya_prospects");
}
if (conn.tableOperations().exists("rya_selectivity")) {
conn.tableOperations().delete("rya_selectivity");
}
arc = new AccumuloRdfConfiguration();
arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
arc.setMaxRangesForScanner(300);
res = new ProspectorServiceEvalStatsDAO(conn, arc);
}
示例15: setAccumuloOutput
import org.apache.accumulo.core.client.security.tokens.PasswordToken; //导入依赖的package包/类
private static void setAccumuloOutput(final String instStr, final String zooStr, final String userStr, final String passStr, final Job job, final String tableName)
throws AccumuloSecurityException {
final AuthenticationToken token = new PasswordToken(passStr);
AccumuloOutputFormat.setConnectorInfo(job, userStr, token);
AccumuloOutputFormat.setDefaultTableName(job, tableName);
AccumuloOutputFormat.setCreateTables(job, true);
//TODO best way to do this?
if (zooStr.equals("mock")) {
AccumuloOutputFormat.setMockInstance(job, instStr);
} else {
AccumuloOutputFormat.setZooKeeperInstance(job, instStr, zooStr);
}
job.setOutputFormatClass(AccumuloOutputFormat.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Mutation.class);
}