/** * * @param ryaInstanceName - The Rya instance to connect to. * @return Constructs a new {@link AccumuloRdfConfiguration} object with values from this object. */ public AccumuloRdfConfiguration buildAccumuloRdfConfiguration(final String ryaInstanceName) { // Note, we don't use the AccumuloRdfConfigurationBuilder here because it explicitly sets // authorizations and visibilities to an empty string if they are not set on the builder. // If they are null in the AccumuloRdfConfiguration object, then Accumulo uses the values stored in accumulo for the user. final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); conf.setTablePrefix(ryaInstanceName); conf.setAccumuloZookeepers(zookeepers); conf.setAccumuloInstance(instanceName); conf.setAccumuloUser(username); conf.setAccumuloPassword(new String(userpass)); return conf; } }
protected AccumuloRdfConfiguration makeConfig(final String instanceName, final String zookeepers) { final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); conf.setTablePrefix(RYA_INSTANCE_NAME); // Accumulo connection information. conf.setAccumuloUser(AccumuloExportITBase.ACCUMULO_USER); conf.setAccumuloPassword(AccumuloExportITBase.ACCUMULO_PASSWORD); conf.setAccumuloInstance(super.getAccumuloConnector().getInstance().getInstanceName()); conf.setAccumuloZookeepers(super.getAccumuloConnector().getInstance().getZooKeepers()); conf.setAuths(""); // PCJ configuration information. conf.set(ConfigUtils.USE_PCJ, "true"); conf.set(ConfigUtils.USE_PCJ_UPDATER_INDEX, "true"); conf.set(ConfigUtils.FLUO_APP_NAME, super.getFluoConfiguration().getApplicationName()); conf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinStorageType.ACCUMULO.toString()); conf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinUpdaterType.FLUO.toString()); conf.setDisplayQueryPlan(true); return conf; }
private static AccumuloRdfConfiguration getConf() { AccumuloRdfConfiguration conf; Set<RyaIRI> propertySet = new HashSet<RyaIRI>(Arrays.asList(new RyaIRI("http://createdBy"), new RyaIRI("http://createdOn"), new RyaIRI("http://hasTimeStamp"))); conf = new AccumuloRdfConfiguration(); conf.setDisplayQueryPlan(false); conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true); conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_"); conf.set(ConfigUtils.CLOUDBASE_USER, "root"); conf.set(ConfigUtils.CLOUDBASE_PASSWORD, ""); conf.set(ConfigUtils.CLOUDBASE_INSTANCE, "instance"); conf.set(ConfigUtils.CLOUDBASE_AUTHS, ""); conf.setUseStatementMetadata(true); conf.setStatementMetadataProperties(propertySet); return conf; }
/** * Get the Accumulo password from the configuration object that is meant to * be used when connecting a {@link Connector} to Accumulo. * * @param conf - The configuration object that will be interrogated. (not null) * @return The password if one could be found; otherwise an empty string. */ public static String getPassword(final Configuration conf) { return new AccumuloRdfConfiguration(conf).getPassword(); }
/** * Indicates that a Mock instance of Accumulo is being used to back the Rya instance. * * @param conf - The configuration object that will be interrogated. (not null) * @return {@code true} if the Rya instance is backed by a mock Accumulo; otherwise {@code false}. */ public static boolean useMockInstance(final Configuration conf) { return new AccumuloRdfConfiguration(conf).useMockInstance(); }
/** * Get the Accumulo username from the configuration object that is meant to * be used when connecting a {@link Connector} to Accumulo. * * @param conf - The configuration object that will be interrogated. (not null) * @return The username if one could be found; otherwise {@code null}. */ public static String getUsername(final Configuration conf) { return new AccumuloRdfConfiguration(conf).getUsername(); }
childUser = childConfig.get(MRUtils.AC_USERNAME_PROP, null); parentAccumuloRdfConfiguration = new AccumuloRdfConfiguration(parentConfig); parentAccumuloRdfConfiguration.setTablePrefix(parentTablePrefix); parentConnector = AccumuloRyaUtils.setupConnector(parentAccumuloRdfConfiguration); childAccumuloRdfConfiguration = new AccumuloRdfConfiguration(childConfig); childAccumuloRdfConfiguration.setTablePrefix(childTablePrefix); childRyaContext = RyaTripleContext.getInstance(childAccumuloRdfConfiguration);
public AccumuloRdfConfiguration toRdfConfiguation() { final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); return conf; }
private Sail connectToRya(final String ryaInstanceName) throws RyaClientException { try { final AccumuloConnectionDetails connectionDetails = super.getAccumuloConnectionDetails(); final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration(); ryaConf.setTablePrefix(ryaInstanceName); ryaConf.set(ConfigUtils.CLOUDBASE_USER, connectionDetails.getUsername()); ryaConf.set(ConfigUtils.CLOUDBASE_PASSWORD, new String(connectionDetails.getUserPass())); ryaConf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, connectionDetails.getZookeepers()); ryaConf.set(ConfigUtils.CLOUDBASE_INSTANCE, connectionDetails.getInstanceName()); // Turn PCJs off so that we will only scan the core Rya tables while building the PCJ results. ryaConf.set(ConfigUtils.USE_PCJ, "false"); return RyaSailFactory.getInstance(ryaConf); } catch (SailException | AccumuloException | AccumuloSecurityException | RyaDAOException | InferenceEngineException e) { throw new RyaClientException("Could not connect to the Rya instance named '" + ryaInstanceName + "'.", e); } }
final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); conf.setTablePrefix(getRyaInstanceName()); conf.setDisplayQueryPlan(true); conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, false); conf.set(ConfigUtils.CLOUDBASE_USER, clusterInstance.getUsername()); conf.set(ConfigUtils.CLOUDBASE_PASSWORD, clusterInstance.getPassword()); conf.set(ConfigUtils.CLOUDBASE_INSTANCE, clusterInstance.getInstanceName()); conf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, clusterInstance.getZookeepers()); conf.set(ConfigUtils.USE_PCJ, "true"); conf.set(ConfigUtils.FLUO_APP_NAME, getRyaInstanceName()); conf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinStorageType.ACCUMULO.toString()); conf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinUpdaterType.FLUO.toString()); conf.set(ConfigUtils.CLOUDBASE_AUTHS, "");
private static AccumuloRyaDAO getRyaIndexer(final Configuration conf) throws IOException { try { if (!conf.getBoolean(ENABLE_CORE, true)) { return null; } final AccumuloRyaDAO ryaIndexer = new AccumuloRyaDAO(); final Connector conn = ConfigUtils.getConnector(conf); ryaIndexer.setConnector(conn); final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration(); final String tablePrefix = conf.get(OUTPUT_PREFIX_PROPERTY, null); if (tablePrefix != null) { ryaConf.setTablePrefix(tablePrefix); } ryaConf.setDisplayQueryPlan(false); ryaIndexer.setConf(ryaConf); ryaIndexer.init(); return ryaIndexer; } catch (final AccumuloException e) { logger.error("Cannot create RyaIndexer", e); throw new IOException(e); } catch (final AccumuloSecurityException e) { logger.error("Cannot create RyaIndexer", e); throw new IOException(e); } catch (final RyaDAOException e) { logger.error("Cannot create RyaIndexer", e); throw new IOException(e); } }
final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration(); conf.setTablePrefix(ryaInstance); conf.setAuths(getAuths(accumulo));
final AccumuloRdfConfiguration aconf = new AccumuloRdfConfiguration(conf); aconf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, mock); aconf.setTablePrefix(tablePrefix); aconf.setFlush(false); ConfigUtils.setIndexers(aconf);
final AccumuloRdfConfiguration config = new AccumuloRdfConfiguration(); config.useMockInstance(true); config.setTablePrefix("rya_"); config.setUsername("user"); config.setPassword("pass"); config.setInstanceName("accumulo");
/** * Create a {@link Connector} that connects to an Accumulo instance. The {@link AccumuloRdfConfiguration#USE_MOCK_INSTANCE} * flag must be set if the configuration information needs to connect to a mock instance of Accumulo. If this is * the case, then the Zookeepers information should not be set. * * @param config - The configuration that will be used to initialize the connector. (not null) * @return The {@link Connector} that was created by {@code config}. * @throws AccumuloException The connector couldn't be created because of an Accumulo problem. * @throws AccumuloSecurityException The connector couldn't be created because of an Accumulo security violation. */ public static Connector connect(AccumuloRdfConfiguration config) throws AccumuloException, AccumuloSecurityException { requireNonNull(config); // Wrap the configuration as the Accumulo configuration so that we may have access // to Accumulo specific configuration values. final AccumuloRdfConfiguration accConf = new AccumuloRdfConfiguration(config); // Create the Mock or Zookeeper backed Instance depending on the configuration. final Instance instance; if(accConf.useMockInstance()) { instance = new MockInstance(accConf.getInstanceName()); } else { instance = new ZooKeeperInstance(accConf.getInstanceName(), accConf.getZookeepers()); } // Return a connector using the configured username and password. return instance.getConnector(accConf.getUsername(), new PasswordToken(accConf.getPassword())); } }
/** * Sets up the configuration and prints the arguments. */ public void setUpConfig() { log.info("Setting " + driverName + " config"); // Setup config if (isMock) { configMap.put(MRUtils.AC_MOCK_PROP, Boolean.TRUE.toString()); } configMap.put(MRUtils.AC_INSTANCE_PROP, instanceName); configMap.put(MRUtils.AC_USERNAME_PROP, user); configMap.put(MRUtils.AC_PWD_PROP, userpwd); configMap.put(MRUtils.TABLE_PREFIX_PROPERTY, tablePrefix); configMap.put(MRUtils.AC_AUTH_PROP, auth); configMap.put(MRUtils.AC_ZK_PROP, zooKeepers != null ? zooKeepers : "localhost"); log.info(driverName + " config properties"); config.setTablePrefix(tablePrefix); for (final Entry<String, String> entry : configMap.entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); final String argument = ToolConfigUtils.makeArgument(isParent ? key : key + MergeTool.CHILD_SUFFIX, value); if (!key.equals(MRUtils.AC_PWD_PROP)) { log.info(argument); } config.set(key, value); } MergeTool.setDuplicateKeys(config); }
/** * Assigns builder values to appropriate parameters within the {@link Configuration} object. * * @param conf - Configuration object * @return - Configuration object with parameters set */ private C getConf(C conf) { conf.setAccumuloInstance(instance); conf.setAccumuloPassword(pass); conf.setAccumuloUser(user); if (!useMock) { conf.setAccumuloZookeepers(zoo); } conf.setUseMockAccumulo(useMock); conf.setPrefixRowsWithHash(usePrefixHashing); if (useSelectivity) { conf.setUseStats(true); conf.setCompositeCardinality(true); conf.setUseSelectivity(useSelectivity); } else if (useComposite) { conf.setUseStats(true); conf.setCompositeCardinality(useComposite); } return conf; }
/** * Create an {@link Instance} that may be used to create {@link Connector}s * to Accumulo. If the configuration has the {@link #USE_MOCK_INSTANCE} flag * set, then the instance will be be a {@link MockInstance} instead of a * Zookeeper backed instance. * * @param conf - The configuration object that will be interrogated. (not null) * @return The {@link Instance} that may be used to connect to Accumulo. */ public static Instance getInstance(final Configuration conf) { // Pull out the Accumulo specific configuration values. final AccumuloRdfConfiguration accConf = new AccumuloRdfConfiguration(conf); final String instanceName = accConf.getInstanceName(); final String zoookeepers = accConf.getZookeepers(); // Create an Instance a mock if the mock flag is set. if (useMockInstance(conf)) { return new MockInstance(instanceName); } // Otherwise create an Instance to a Zookeeper managed instance of Accumulo. return new ZooKeeperInstance(instanceName, zoookeepers); }
/** * Creates a new instance of {@link AccumuloInstanceDriver}. * @param driverName the name used to identify this driver in the logs. (not {@code null}) * @param isMock {@code true} if the instance will use {@link MockInstance}s. * {@code false} if the instance will use {@link MiniAccumuloCluster}s. * @param shouldCreateIndices {@code true} to create all the indices associated with a Rya deployment. * {@code false} otherwise. * @param isReadOnly {@code true} if all the tables in the instance should have their * table permissions set to read only. {@code false} if the table permission are set to write. * @param isParent {@code true} if the instance is the parent/main instance. {@code false} if it's the * child. * @param user the user name tied to this instance. * @param userpwd the userpwd for the user. * @param instanceName the name of the instance. * @param tablePrefix the table prefix. * @param auth the comma-separated authorization list. */ public AccumuloInstanceDriver(final String driverName, final boolean isMock, final boolean shouldCreateIndices, final boolean isReadOnly, final boolean isParent, final String user, final String userpwd, final String instanceName, final String tablePrefix, final String auth) { this.driverName = Preconditions.checkNotNull(driverName); this.isMock = isMock; this.shouldCreateIndices = shouldCreateIndices; this.isReadOnly = isReadOnly; this.user = user; this.userpwd = userpwd; this.instanceName = instanceName; this.tablePrefix = tablePrefix; this.auth = auth; this.isParent = isParent; config.setTablePrefix(tablePrefix); }
/** * Sets the Accumulo username from the configuration object that is meant to * be used when connecting a {@link Connector} to Accumulo. * */ public void setAccumuloUser(String user) { Preconditions.checkNotNull(user); set(CLOUDBASE_USER, user); }