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


Java Instance.getConnector方法代码示例

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


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

示例1: DataStore

import org.apache.accumulo.core.client.Instance; //导入方法依赖的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.Instance; //导入方法依赖的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.Instance; //导入方法依赖的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: MockRdfCloudStore

import org.apache.accumulo.core.client.Instance; //导入方法依赖的package包/类
public MockRdfCloudStore() {
    super();
    final Instance instance = new MockInstance();
    try {
        final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
        setConf(conf);

        final Connector connector = instance.getConnector("", "");
        final AccumuloRyaDAO cdao = new AccumuloRyaDAO();
        cdao.setConf(conf);
        cdao.setConnector(connector);
        setRyaDAO(cdao);
        inferenceEngine = new InferenceEngine();
        inferenceEngine.setRyaDAO(cdao);
        inferenceEngine.setRefreshGraphSchedule(5000); //every 5 sec
        inferenceEngine.setConf(conf);
        setInferenceEngine(inferenceEngine);
    } catch (final Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:ArbitraryLengthQueryTest.java

示例5: MockRdfCloudStore

import org.apache.accumulo.core.client.Instance; //导入方法依赖的package包/类
public MockRdfCloudStore() {
    super();
    Instance instance = new MockInstance();
    try {
        AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
        conf.setInfer(true);
        setConf(conf);
        Connector connector = instance.getConnector("", "");
        AccumuloRyaDAO cdao = new AccumuloRyaDAO();
        cdao.setConf(conf);
        cdao.setConnector(connector);
        setRyaDAO(cdao);
        inferenceEngine = new InferenceEngine();
        inferenceEngine.setRyaDAO(cdao);
        inferenceEngine.setRefreshGraphSchedule(5000); //every 5 sec
        inferenceEngine.setConf(conf);
        setInferenceEngine(inferenceEngine);
        internalInferenceEngine = inferenceEngine;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:RdfCloudTripleStoreConnectionTest.java

示例6: MockRdfCloudStore

import org.apache.accumulo.core.client.Instance; //导入方法依赖的package包/类
public MockRdfCloudStore() {
    super();
    Instance instance = new MockInstance();
    try {
        Connector connector = instance.getConnector("", "");
        setConf(new AccumuloRdfConfiguration());
        AccumuloRyaDAO cdao = new AccumuloRyaDAO();
        cdao.setConnector(connector);
        setRyaDAO(cdao);
        inferenceEngine = new InferenceEngine();
        inferenceEngine.setRyaDAO(cdao);
        inferenceEngine.setRefreshGraphSchedule(1000); //every sec
        setInferenceEngine(inferenceEngine);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:CbSailTest.java

示例7: connect

import org.apache.accumulo.core.client.Instance; //导入方法依赖的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

示例8: getConnector

import org.apache.accumulo.core.client.Instance; //导入方法依赖的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: getMockConnector

import org.apache.accumulo.core.client.Instance; //导入方法依赖的package包/类
/**
 * For testing.
 *
 * @param instance
 * @param user
 * @param pass
 * @return
 */
public static Connector getMockConnector(String instance, String user,
    String pass) throws DataProviderException
{
  Instance mock = new MockInstance(instance);
  Connector conn = null;
  try
  {
    conn = mock.getConnector(user, pass.getBytes());
  }
  catch (Exception e)
  {
    throw new DataProviderException(
        "problem creating mock connector - " + e.getMessage(), e);
  }

  return conn;
}
 
开发者ID:ngageoint,项目名称:mrgeo,代码行数:26,代码来源:AccumuloConnector.java

示例10: setQueryInfo

import org.apache.accumulo.core.client.Instance; //导入方法依赖的package包/类
public static void setQueryInfo(Job job, Set<String> entityTypes, Node query, EntityShardBuilder shardBuilder, TypeRegistry<String> typeRegistry) throws AccumuloSecurityException, AccumuloException, TableNotFoundException, IOException {

        validateOptions(job);

        checkNotNull(shardBuilder);
        checkNotNull(query);
        checkNotNull(entityTypes);
        checkNotNull(typeRegistry);

        Instance instance = getInstance(job);
        Connector connector = instance.getConnector(getPrincipal(job), getAuthenticationToken(job));
        BatchScanner scanner = connector.createBatchScanner(DEFAULT_IDX_TABLE_NAME, getScanAuthorizations(job), 5);
        GlobalIndexVisitor globalIndexVisitor = new EntityGlobalIndexVisitor(scanner, shardBuilder, entityTypes);

        configureScanner(job, entityTypes, query, new NodeToJexl(typeRegistry), globalIndexVisitor, typeRegistry, OptimizedQueryIterator.class);

        job.getConfiguration().setBoolean(QUERY, true);
        job.getConfiguration().set(TYPE_REGISTRY, new String(toBase64(typeRegistry)));
    }
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:20,代码来源:EntityInputFormat.java

示例11: main

import org.apache.accumulo.core.client.Instance; //导入方法依赖的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

示例12: getConnector

import org.apache.accumulo.core.client.Instance; //导入方法依赖的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

示例13: initialize

import org.apache.accumulo.core.client.Instance; //导入方法依赖的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

示例14: init

import org.apache.accumulo.core.client.Instance; //导入方法依赖的package包/类
@Before
public void init() throws Exception {
    conf = getConf();
    Instance mock = new MockInstance("instance");
    Connector conn = mock.getConnector("root", new PasswordToken(""));
    dao = new AccumuloRyaDAO();
    dao.setConnector(conn);
    dao.init();
    eval = new ParallelEvaluationStrategyImpl(new StoreTripleSource(conf, dao), null, null, conf);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:11,代码来源:StatementPatternEvalTest.java

示例15: getSplits

import org.apache.accumulo.core.client.Instance; //导入方法依赖的package包/类
@Override
public List<InputSplit> getSplits(JobContext jobContext) throws IOException {
    //read the params from AccumuloInputFormat
    Configuration conf = jobContext.getConfiguration();
    Instance instance = MRUtils.AccumuloProps.getInstance(jobContext);
    String user = MRUtils.AccumuloProps.getUsername(jobContext);
    AuthenticationToken password = MRUtils.AccumuloProps.getPassword(jobContext);
    String table = MRUtils.AccumuloProps.getTablename(jobContext);
    ArgumentChecker.notNull(instance);
    ArgumentChecker.notNull(table);

    //find the files necessary
    try {
        Connector connector = instance.getConnector(user, password);
        TableOperations tos = connector.tableOperations();
        String tableId = tos.tableIdMap().get(table);
        Scanner scanner = connector.createScanner("accumulo.metadata", Authorizations.EMPTY); //TODO: auths?
        scanner.setRange(new Range(new Text(tableId + "\u0000"), new Text(tableId + "\uFFFD")));
        scanner.fetchColumnFamily(new Text("file"));
        List<String> files = new ArrayList<String>();
        List<InputSplit> fileSplits = new ArrayList<InputSplit>();
        for (Map.Entry<Key, Value> entry : scanner) {
            String file = entry.getKey().getColumnQualifier().toString();
            Path path = new Path(file);
            FileSystem fs = path.getFileSystem(conf);
            FileStatus fileStatus = fs.getFileStatus(path);
            long len = fileStatus.getLen();
            BlockLocation[] fileBlockLocations = fs.getFileBlockLocations(fileStatus, 0, len);
            files.add(file);
            fileSplits.add(new FileSplit(path, 0, len, fileBlockLocations[0].getHosts()));
        }
        System.out.println(files);
        return fileSplits;
    } catch (Exception e) {
        throw new IOException(e);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:38,代码来源:AccumuloHDFSFileInputFormat.java


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