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


Java Instance类代码示例

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


Instance类属于org.apache.accumulo.core.client包,在下文中一共展示了Instance类的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: loadDataAndCreateQuery

import org.apache.accumulo.core.client.Instance; //导入依赖的package包/类
protected String loadDataAndCreateQuery(final String sparql, final Collection<Statement> statements) throws Exception {
    requireNonNull(sparql);
    requireNonNull(statements);

    // Register the PCJ with Rya.
    final Instance accInstance = super.getAccumuloConnector().getInstance();
    final Connector accumuloConn = super.getAccumuloConnector();

    final RyaClient ryaClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ACCUMULO_USER,
            ACCUMULO_PASSWORD.toCharArray(), accInstance.getInstanceName(), accInstance.getZooKeepers()), accumuloConn);

    final String pcjId = ryaClient.getCreatePCJ().createPCJ(RYA_INSTANCE_NAME, sparql, Sets.newHashSet(ExportStrategy.KAFKA));

    loadData(statements);

    // The PCJ Id is the topic name the results will be written to.
    return pcjId;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:19,代码来源:KafkaExportITBase.java

示例8: getParams

import org.apache.accumulo.core.client.Instance; //导入依赖的package包/类
public Map<String, Serializable> getParams(final Configuration conf) {
    // get the configuration parameters
    final Instance instance = ConfigUtils.getInstance(conf);
    final String instanceId = instance.getInstanceName();
    final String zookeepers = instance.getZooKeepers();
    final String user = ConfigUtils.getUsername(conf);
    final String password = ConfigUtils.getPassword(conf);
    final String auths = ConfigUtils.getAuthorizations(conf).toString();
    final String tableName = getTableName(conf);
    final String tablePrefix = ConfigUtils.getTablePrefix(conf);

    final Map<String, Serializable> params = new HashMap<>();
    params.put("zookeeper", zookeepers);
    params.put("instance", instanceId);
    params.put("user", user);
    params.put("password", password);
    params.put("namespace", tableName);
    params.put("gwNamespace", tablePrefix + getClass().getSimpleName());

    params.put("Lock Management", LockManagementType.MEMORY.toString());
    params.put("Authorization Management Provider", AuthorizationManagementProviderType.EMPTY.toString());
    params.put("Authorization Data URL", null);
    params.put("Transaction Buffer Size", 10000);
    params.put("Query Index Strategy", QueryIndexStrategyType.HEURISTIC_MATCH.toString());
    return params;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:GeoWaveGeoIndexer.java

示例9: createDataStore

import org.apache.accumulo.core.client.Instance; //导入依赖的package包/类
/**
 * Creates the {@link DataStore} for the {@link GeoWaveGeoIndexer}.
 * @param conf the {@link Configuration}.
 * @return the {@link DataStore}.
 */
public DataStore createDataStore(final Configuration conf) throws IOException, GeoWavePluginException {
    final Map<String, Serializable> params = getParams(conf);
    final Instance instance = ConfigUtils.getInstance(conf);
    final boolean useMock = instance instanceof MockInstance;

    final StoreFactoryFamilySpi storeFactoryFamily;
    if (useMock) {
        storeFactoryFamily = new MemoryStoreFactoryFamily();
    } else {
        storeFactoryFamily = new AccumuloStoreFactoryFamily();
    }

    final GeoWaveGTDataStoreFactory geoWaveGTDataStoreFactory = new GeoWaveGTDataStoreFactory(storeFactoryFamily);
    final DataStore dataStore = geoWaveGTDataStoreFactory.createNewDataStore(params);

    return dataStore;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:GeoWaveGeoIndexer.java

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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