当前位置: 首页>>代码示例>>Java>>正文


Java ZooKeeperInstance类代码示例

本文整理汇总了Java中org.apache.accumulo.core.client.ZooKeeperInstance的典型用法代码示例。如果您正苦于以下问题:Java ZooKeeperInstance类的具体用法?Java ZooKeeperInstance怎么用?Java ZooKeeperInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ZooKeeperInstance类属于org.apache.accumulo.core.client包,在下文中一共展示了ZooKeeperInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DataStore

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的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);
        }
    }
 
开发者ID:NationalSecurityAgency,项目名称:qonduit,代码行数:17,代码来源:DataStore.java

示例2: main

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的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();
            }
        }
    }
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:27,代码来源:GetMetricTableSplitPoints.java

示例3: content

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的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);
  
}
 
开发者ID:apache,项目名称:accumulo-wikisearch,代码行数:25,代码来源:Query.java

示例4: ExportTask

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的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());
  }
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:20,代码来源:AccumuloWriter.java

示例5: connect

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
/**
 * Create a {@link Connector} that uses the provided connection details.
 *
 * @param username - The username the connection will use. (not null)
 * @param password - The password the connection will use. (not null)
 * @param instanceName - The name of the Accumulo instance. (not null)
 * @param zookeeperHostnames - A comma delimited list of the Zookeeper server hostnames. (not null)
 * @return A {@link Connector} that may be used to access the instance of Accumulo.
 * @throws AccumuloSecurityException Could not connect for security reasons.
 * @throws AccumuloException Could not connect for other reasons.
 */
public Connector connect(
        final String username,
        final CharSequence password,
        final String instanceName,
        final String zookeeperHostnames) throws AccumuloException, AccumuloSecurityException {
    requireNonNull(username);
    requireNonNull(password);
    requireNonNull(instanceName);
    requireNonNull(zookeeperHostnames);

    // Setup the password token that will be used.
    final PasswordToken token = new PasswordToken( password );

    // Connect to the instance of Accumulo.
    final Instance instance = new ZooKeeperInstance(instanceName, zookeeperHostnames);
    return instance.getConnector(username, token);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:29,代码来源:ConnectorFactory.java

示例6: main

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  FluoConfiguration config = new FluoConfiguration(new File(args[0]));

  String exportTable = args[1];

  Connector conn =
      new ZooKeeperInstance(config.getAccumuloInstance(), config.getAccumuloZookeepers())
          .getConnector("root", new PasswordToken("secret"));
  try {
    conn.tableOperations().delete(exportTable);
  } catch (TableNotFoundException e) {
    // ignore if table not found
  }

  conn.tableOperations().create(exportTable);

  Options opts = new Options(103, 103, config.getAccumuloInstance(), config.getAccumuloZookeepers(),
      config.getAccumuloUser(), config.getAccumuloPassword(), exportTable);

  FluoConfiguration observerConfig = new FluoConfiguration();
  Application.configure(observerConfig, opts);
  observerConfig.save(System.out);
}
 
开发者ID:astralway,项目名称:phrasecount,代码行数:24,代码来源:Setup.java

示例7: main

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  if (args.length != 2) {
    System.err.println("Usage : " + Split.class.getName() + " <fluo props file> <table name>");
    System.exit(-1);
  }

  FluoConfiguration fluoConfig = new FluoConfiguration(new File(args[0]));
  ZooKeeperInstance zki =
      new ZooKeeperInstance(fluoConfig.getAccumuloInstance(), fluoConfig.getAccumuloZookeepers());
  Connector conn = zki.getConnector(fluoConfig.getAccumuloUser(),
      new PasswordToken(fluoConfig.getAccumuloPassword()));

  SortedSet<Text> splits = new TreeSet<>();

  for (char c = 'b'; c < 'z'; c++) {
    splits.add(new Text("phrase:" + c));
  }

  conn.tableOperations().addSplits(args[1], splits);

  // TODO figure what threads are hanging around
  System.exit(0);
}
 
开发者ID:astralway,项目名称:phrasecount,代码行数:24,代码来源:Split.java

示例8: getConnector

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
public static synchronized Connector getConnector(String instance, String zookeepers,
    String user, String pass) throws DataProviderException
{

  if (conn != null)
  {
    return conn;
  }
  if (checkMock())
  {
    return getMockConnector(instance, user, pass);
  }

  Instance inst = new ZooKeeperInstance(instance, zookeepers);
  try
  {
    conn = inst.getConnector(user, new PasswordToken(pass.getBytes()));
    return conn;
  }
  catch (Exception e)
  {
    throw new DataProviderException("problem creating connector", e);
  }
}
 
开发者ID:ngageoint,项目名称:mrgeo,代码行数:25,代码来源:AccumuloConnector.java

示例9: testGetGeoTables

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
@Test
@Category(UnitTest.class)
public void testGetGeoTables() throws Exception
{
  ZooKeeperInstance zkinst = new ZooKeeperInstance(inst, zoo);
  PasswordToken pwTok = new PasswordToken(pw.getBytes());
  Connector conn = zkinst.getConnector(u, pwTok);
  Assert.assertNotNull(conn);

  PasswordToken token = new PasswordToken(pw.getBytes());

  //Authorizations auths = new Authorizations(authsStr.split(","));
  Authorizations auths = new Authorizations("A,B,C,D,ROLE_USER,U".split(","));
  System.out.println(auths.toString());
  Hashtable<String, String> ht = AccumuloUtils.getGeoTables(null, token, auths, conn);
  for (String k : ht.keySet())
  {
    System.out.println(k + " => " + ht.get(k));
  }


}
 
开发者ID:ngageoint,项目名称:mrgeo,代码行数:23,代码来源:AccumuloGeoTableTest.java

示例10: OsmProvider

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
public OsmProvider(
		OSMIngestCommandArgs args,
		AccumuloRequiredOptions store )
		throws AccumuloSecurityException,
		AccumuloException,
		TableNotFoundException {
	conn = new ZooKeeperInstance(
			store.getInstance(),
			store.getZookeeper()).getConnector(
			store.getUser(),
			new PasswordToken(
					store.getPassword()));
	bs = conn.createBatchScanner(
			args.getQualifiedTableName(),
			new Authorizations(
					args.getVisibilityOptions().getVisibility()),
			1);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:19,代码来源:OsmProvider.java

示例11: createAccumuloCluster

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
@BeforeClass
public static void createAccumuloCluster() throws Exception {
  macDir = File.createTempFile("miniaccumulocluster", null);
  Assert.assertTrue(macDir.delete());
  Assert.assertTrue(macDir.mkdir());
  macDir.deleteOnExit();
  
  MiniAccumuloConfig config = new MiniAccumuloConfig(macDir, "");
  config.setNumTservers(2);
  
  mac = new MiniAccumuloCluster(config);
  mac.start();
  
  ZooKeeperInstance zkInst = new ZooKeeperInstance(mac.getInstanceName(), mac.getZooKeepers());
  Connector c = zkInst.getConnector("root", new PasswordToken(""));
  
  // Add in auths for "en"
  c.securityOperations().changeUserAuthorizations("root", new Authorizations("en"));
  
  zk = new TestingServer();
}
 
开发者ID:joshelser,项目名称:cosmos,代码行数:22,代码来源:CosmosIntegrationTest.java

示例12: setupMAC

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
@BeforeClass
public static void setupMAC() throws Exception {
  File tmp = Files.createTempDir();
  tmp.deleteOnExit();
  conf = new MiniAccumuloConfig(tmp, "foo");
  conf.setNumTservers(2);
  mac = new MiniAccumuloCluster(conf);
  mac.start();

  
  ZooKeeperInstance zkInst = new ZooKeeperInstance(mac.getInstanceName(), mac.getZooKeepers());
  Connector con = zkInst.getConnector("root", new PasswordToken("foo"));
  con.tableOperations().create(Defaults.DATA_TABLE);
  con.tableOperations().create(Defaults.METADATA_TABLE);

  zk = new TestingServer();
}
 
开发者ID:joshelser,项目名称:cosmos,代码行数:18,代码来源:GroupByIntegrationTest.java

示例13: main

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
public static void main(String args[]) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {

        if (args.length != 7) {
            System.out.println("Usage: " + DailyShardSplitter.class.getName() + "<zookeepers> <instance> <username> <password> <tableName> <start day: yyyy-mm-dd> <stop day: yyyy-mm-dd>");
            System.exit(1);
        }

        String zookeepers = args[0];
        String instance = args[1];
        String username = args[2];
        String password = args[3];
        String tableName = args[4];
        DateTime start = DateTime.parse(args[5]);
        DateTime stop = DateTime.parse(args[6]);


        Instance accInst = new ZooKeeperInstance(instance, zookeepers);
        Connector connector = accInst.getConnector(username, password.getBytes());

        SortedSet<Text> shards = new DailyShardBuilder(Constants.DEFAULT_PARTITION_SIZE)
                .buildShardsInRange(start.toDate(), stop.toDate());

        connector.tableOperations().addSplits(tableName, shards);
    }
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:25,代码来源:DailyShardSplitter.java

示例14: getConnector

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
public Connector getConnector() throws AccumuloException {
	try {
		if (connector == null) {
			if (mock) {
				connector = new MockInstance().getConnector("", "");				
			}
			else {
				Instance inst = new ZooKeeperInstance(instance, zookeepers);
				connector = inst.getConnector(username, password);				
			}

			password = null;
		}

		return connector;

	} catch (AccumuloSecurityException e) {
		throw new AccumuloException(e);
	}
}
 
开发者ID:mikelieberman,项目名称:blueprints-accumulo-graph,代码行数:21,代码来源:AccumuloGraphOptions.java

示例15: initialize

import org.apache.accumulo.core.client.ZooKeeperInstance; //导入依赖的package包/类
protected final void initialize(File dir, String pw) throws RebarException {
  try {
    // this.cfg = cfg;
    this.cluster = new MiniAccumuloCluster(dir, pw);
    this.cluster.start();
    logger.info("Started. Sleeping.");
    Thread.sleep(3000);
    Instance inst = new ZooKeeperInstance(this.cluster.getInstanceName(), this.cluster.getZooKeepers());
    logger.info("Got instance.");
    Connector conn = inst.getConnector("root", new PasswordToken(pw));
    logger.info("Got connector.");
    super.initialize(conn);
  } catch (IOException | InterruptedException | AccumuloException | AccumuloSecurityException e) {
    throw new RebarException(e);
  }
}
 
开发者ID:hltcoe,项目名称:rebar,代码行数:17,代码来源:AbstractMiniClusterTest.java


注:本文中的org.apache.accumulo.core.client.ZooKeeperInstance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。