Search in sources :

Example 1 with AccumuloRequiredOptions

use of org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions in project geowave by locationtech.

the class AccumuloStoreTestEnvironment method initOptions.

@Override
protected void initOptions(final StoreFactoryOptions options) {
    final AccumuloRequiredOptions accumuloOpts = (AccumuloRequiredOptions) options;
    if (KerberosTestEnvironment.useKerberos()) {
        final ClusterUser rootUser = KerberosTestEnvironment.getInstance().getRootUser();
        accumuloOpts.setUser(rootUser.getPrincipal());
        accumuloOpts.setKeytab(rootUser.getKeytab().getAbsolutePath());
        accumuloOpts.setUseSasl(true);
    } else {
        accumuloOpts.setUser(accumuloUser);
        accumuloOpts.setPassword(accumuloPassword);
    }
    accumuloOpts.setInstance(accumuloInstance);
    accumuloOpts.setZookeeper(zookeeper);
}
Also used : AccumuloRequiredOptions(org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions) ClusterUser(org.apache.accumulo.cluster.ClusterUser)

Example 2 with AccumuloRequiredOptions

use of org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions in project geowave by locationtech.

the class OSMConversionRunner method run.

@Override
public int run(final String[] args) throws Exception {
    final Configuration conf = getConf();
    final AccumuloRequiredOptions accumuloOptions = (AccumuloRequiredOptions) inputStoreOptions.getFactoryOptions();
    // job settings
    final Job job = Job.getInstance(conf, ingestOptions.getJobName() + "NodeConversion");
    job.setJarByClass(OSMConversionRunner.class);
    job.getConfiguration().set("osm_mapping", ingestOptions.getMappingContents());
    job.getConfiguration().set("arguments", ingestOptions.serializeToString());
    if (ingestOptions.getVisibilityOptions().getGlobalVisibility() != null) {
        job.getConfiguration().set(AbstractMapReduceIngest.GLOBAL_VISIBILITY_KEY, ingestOptions.getVisibilityOptions().getGlobalVisibility());
    }
    // input format
    AbstractInputFormat.setConnectorInfo(job, accumuloOptions.getUser(), new PasswordToken(accumuloOptions.getPassword()));
    InputFormatBase.setInputTableName(job, ingestOptions.getQualifiedTableName());
    AbstractInputFormat.setZooKeeperInstance(job, ClientConfiguration.create().withInstance(accumuloOptions.getInstance()).withZkHosts(accumuloOptions.getZookeeper()));
    AbstractInputFormat.setScanAuthorizations(job, new Authorizations(ingestOptions.getVisibilityOptions().getGlobalVisibility()));
    final IteratorSetting is = new IteratorSetting(50, "WholeRow", WholeRowIterator.class);
    InputFormatBase.addIterator(job, is);
    job.setInputFormatClass(AccumuloInputFormat.class);
    final Range r = new Range();
    // final ArrayList<Pair<Text, Text>> columns = new ArrayList<>();
    InputFormatBase.setRanges(job, Arrays.asList(r));
    // output format
    GeoWaveOutputFormat.setStoreOptions(job.getConfiguration(), inputStoreOptions);
    final AccumuloOptions options = new AccumuloOptions();
    final AdapterStore as = new AdapterStoreImpl(new AccumuloOperations(accumuloOptions.getZookeeper(), accumuloOptions.getInstance(), accumuloOptions.getUser(), accumuloOptions.getPasswordOrKeytab(), accumuloOptions.isUseSasl(), accumuloOptions.getGeoWaveNamespace(), options), options);
    for (final FeatureDataAdapter fda : FeatureDefinitionSet.featureAdapters.values()) {
        as.addAdapter(fda);
        GeoWaveOutputFormat.addDataAdapter(job.getConfiguration(), fda);
    }
    final Index primaryIndex = SpatialDimensionalityTypeProvider.createIndexFromOptions(new SpatialOptions());
    GeoWaveOutputFormat.addIndex(job.getConfiguration(), primaryIndex);
    job.getConfiguration().set(AbstractMapReduceIngest.INDEX_NAMES_KEY, primaryIndex.getName());
    job.setOutputFormatClass(GeoWaveOutputFormat.class);
    job.setMapOutputKeyClass(GeoWaveOutputKey.class);
    job.setMapOutputValueClass(SimpleFeature.class);
    // mappper
    job.setMapperClass(OSMConversionMapper.class);
    // reducer
    job.setNumReduceTasks(0);
    return job.waitForCompletion(true) ? 0 : -1;
}
Also used : Authorizations(org.apache.accumulo.core.security.Authorizations) AccumuloOperations(org.locationtech.geowave.datastore.accumulo.operations.AccumuloOperations) Configuration(org.apache.hadoop.conf.Configuration) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Index(org.locationtech.geowave.core.store.api.Index) Range(org.apache.accumulo.core.data.Range) SpatialOptions(org.locationtech.geowave.core.geotime.index.SpatialOptions) AdapterStore(org.locationtech.geowave.core.store.adapter.AdapterStore) AccumuloRequiredOptions(org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) AccumuloOptions(org.locationtech.geowave.datastore.accumulo.config.AccumuloOptions) Job(org.apache.hadoop.mapreduce.Job) AdapterStoreImpl(org.locationtech.geowave.core.store.metadata.AdapterStoreImpl) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter)

Example 3 with AccumuloRequiredOptions

use of org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions in project geowave by locationtech.

the class MinimalFullTable method execute.

@Override
public void execute(final OperationParams params) throws ParseException {
    final StopWatch stopWatch = new StopWatch();
    // Ensure we have all the required arguments
    if (parameters.size() != 1) {
        throw new ParameterException("Requires arguments: <storename>");
    }
    final String storeName = parameters.get(0);
    // Attempt to load store.
    final DataStorePluginOptions storeOptions = CLIUtils.loadStore(storeName, getGeoWaveConfigFile(params), params.getConsole());
    final String storeType = storeOptions.getType();
    if (storeType.equals(AccumuloStoreFactoryFamily.TYPE)) {
        try {
            final AccumuloRequiredOptions opts = (AccumuloRequiredOptions) storeOptions.getFactoryOptions();
            final AccumuloOperations ops = new AccumuloOperations(opts.getZookeeper(), opts.getInstance(), opts.getUser(), opts.getPasswordOrKeytab(), opts.isUseSasl(), opts.getGeoWaveNamespace(), (AccumuloOptions) opts.getStoreOptions());
            long results = 0;
            final BatchScanner scanner = ops.createBatchScanner(indexId);
            scanner.setRanges(Collections.singleton(new Range()));
            final Iterator<Entry<Key, Value>> it = scanner.iterator();
            stopWatch.start();
            while (it.hasNext()) {
                it.next();
                results++;
            }
            stopWatch.stop();
            scanner.close();
            System.out.println("Got " + results + " results in " + stopWatch.toString());
        } catch (AccumuloException | AccumuloSecurityException | TableNotFoundException | IOException e) {
            LOGGER.error("Unable to scan accumulo datastore", e);
        }
    } else if (storeType.equals(HBaseStoreFactoryFamily.TYPE)) {
        throw new UnsupportedOperationException("full scan for store type " + storeType + " not yet implemented.");
    } else {
        throw new UnsupportedOperationException("full scan for store type " + storeType + " not implemented.");
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) AccumuloOperations(org.locationtech.geowave.datastore.accumulo.operations.AccumuloOperations) BatchScanner(org.apache.accumulo.core.client.BatchScanner) IOException(java.io.IOException) Range(org.apache.accumulo.core.data.Range) StopWatch(org.apache.commons.lang3.time.StopWatch) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloRequiredOptions(org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions) Entry(java.util.Map.Entry) DataStorePluginOptions(org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions) ParameterException(com.beust.jcommander.ParameterException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException)

Example 4 with AccumuloRequiredOptions

use of org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions in project geowave by locationtech.

the class OSMConversionMapper method setup.

@Override
protected void setup(final Context context) throws IOException, InterruptedException {
    super.setup(context);
    try {
        globalVisibility = context.getConfiguration().get(AbstractMapReduceIngest.GLOBAL_VISIBILITY_KEY);
        final String primaryIndexIdStr = context.getConfiguration().get(AbstractMapReduceIngest.INDEX_NAMES_KEY);
        if (primaryIndexIdStr != null) {
            indexName = primaryIndexIdStr;
        }
        final OSMIngestCommandArgs args = new OSMIngestCommandArgs();
        args.deserializeFromString(context.getConfiguration().get("arguments"));
        final DataStorePluginOptions storeOptions = GeoWaveOutputFormat.getStoreOptions(context);
        osmProvider = new OsmProvider(args, (AccumuloRequiredOptions) storeOptions.getFactoryOptions());
    } catch (final Exception e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : AccumuloRequiredOptions(org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions) OSMIngestCommandArgs(org.locationtech.geowave.cli.osm.operations.options.OSMIngestCommandArgs) DataStorePluginOptions(org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions) OsmProvider(org.locationtech.geowave.cli.osm.mapreduce.Convert.OsmProvider.OsmProvider) IOException(java.io.IOException)

Example 5 with AccumuloRequiredOptions

use of org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions in project geowave by locationtech.

the class AccumuloDataStoreFactory method createStore.

@Override
public DataStore createStore(final StoreFactoryOptions options) {
    if (!(options instanceof AccumuloRequiredOptions)) {
        throw new AssertionError("Expected " + AccumuloRequiredOptions.class.getSimpleName());
    }
    final AccumuloRequiredOptions opts = (AccumuloRequiredOptions) options;
    if (opts.getStoreOptions() == null) {
        opts.setStoreOptions(new AccumuloOptions());
    }
    final DataStoreOperations accumuloOperations = helper.createOperations(opts);
    return new AccumuloDataStore((AccumuloOperations) accumuloOperations, (AccumuloOptions) opts.getStoreOptions());
}
Also used : AccumuloRequiredOptions(org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions) DataStoreOperations(org.locationtech.geowave.core.store.operations.DataStoreOperations) AccumuloOptions(org.locationtech.geowave.datastore.accumulo.config.AccumuloOptions)

Aggregations

AccumuloRequiredOptions (org.locationtech.geowave.datastore.accumulo.config.AccumuloRequiredOptions)6 IOException (java.io.IOException)3 AccumuloOperations (org.locationtech.geowave.datastore.accumulo.operations.AccumuloOperations)3 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)2 Range (org.apache.accumulo.core.data.Range)2 Index (org.locationtech.geowave.core.store.api.Index)2 DataStorePluginOptions (org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions)2 AccumuloOptions (org.locationtech.geowave.datastore.accumulo.config.AccumuloOptions)2 ParameterException (com.beust.jcommander.ParameterException)1 Entry (java.util.Map.Entry)1 ClusterUser (org.apache.accumulo.cluster.ClusterUser)1 BatchScanner (org.apache.accumulo.core.client.BatchScanner)1 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)1 Connector (org.apache.accumulo.core.client.Connector)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)1 Authorizations (org.apache.accumulo.core.security.Authorizations)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1