Search in sources :

Example 1 with PropertyStore

use of org.locationtech.geowave.core.store.PropertyStore in project geowave by locationtech.

the class MigrationCommand method execute.

/**
 * Prep the driver & run the operation.
 */
@Override
public void execute(final OperationParams params) {
    if (parameters.size() != 1) {
        throw new ParameterException("Requires arguments: <store name>");
    }
    final String storeName = parameters.get(0);
    final StoreLoader inputStoreLoader = new StoreLoader(storeName);
    if (!inputStoreLoader.loadFromConfig(getGeoWaveConfigFile(), params.getConsole())) {
        throw new ParameterException("Cannot find store name: " + inputStoreLoader.getStoreName());
    }
    final DataStorePluginOptions storeOptions = inputStoreLoader.getDataStorePlugin();
    final DataStoreOperations operations = storeOptions.createDataStoreOperations();
    final PropertyStore propertyStore = storeOptions.createPropertyStore();
    try {
        if (!operations.metadataExists(MetadataType.ADAPTER) && !operations.metadataExists(MetadataType.INDEX)) {
            throw new ParameterException("There is no data in the data store to migrate.");
        }
    } catch (final IOException e) {
        throw new RuntimeException("Unable to determine if metadata tables exist for data store.", e);
    }
    final DataStoreProperty dataVersionProperty = propertyStore.getProperty(BaseDataStoreUtils.DATA_VERSION_PROPERTY);
    final int dataVersion = dataVersionProperty == null ? 0 : (int) dataVersionProperty.getValue();
    if (dataVersion == BaseDataStoreUtils.DATA_VERSION) {
        throw new ParameterException("The data version matches the CLI version, there are no migrations to apply.");
    }
    if (dataVersion > BaseDataStoreUtils.DATA_VERSION) {
        throw new ParameterException("The data store is using a newer serialization format.  Please update to a newer version " + "of the CLI that is compatible with the data store.");
    }
    // Do migration
    if (dataVersion < 1) {
        migrate0to1(storeOptions, operations, params.getConsole());
    }
    propertyStore.setProperty(new DataStoreProperty(BaseDataStoreUtils.DATA_VERSION_PROPERTY, BaseDataStoreUtils.DATA_VERSION));
    params.getConsole().println("Migration completed successfully!");
}
Also used : DataStoreOperations(org.locationtech.geowave.core.store.operations.DataStoreOperations) DataStorePluginOptions(org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions) DataStoreProperty(org.locationtech.geowave.core.store.DataStoreProperty) ParameterException(com.beust.jcommander.ParameterException) StoreLoader(org.locationtech.geowave.core.store.cli.store.StoreLoader) IOException(java.io.IOException) PropertyStore(org.locationtech.geowave.core.store.PropertyStore)

Example 2 with PropertyStore

use of org.locationtech.geowave.core.store.PropertyStore in project geowave by locationtech.

the class BaseDataStoreUtils method verifyCLIVersion.

public static void verifyCLIVersion(final String storeName, final DataStorePluginOptions options) {
    final DataStoreOperations operations = options.createDataStoreOperations();
    final PropertyStore propertyStore = options.createPropertyStore();
    final DataStoreProperty storeVersionProperty = propertyStore.getProperty(DATA_VERSION_PROPERTY);
    if ((storeVersionProperty == null) && !hasMetadata(operations, MetadataType.ADAPTER) && !hasMetadata(operations, MetadataType.INDEX)) {
        // Nothing has been loaded into the store yet
        return;
    }
    final int storeVersion = storeVersionProperty == null ? 0 : (int) storeVersionProperty.getValue();
    if (storeVersion < DATA_VERSION) {
        throw new ParameterException("The data store '" + storeName + "' is using an older serialization format.  Either use an older " + "version of the CLI that is compatible with the data store, or migrate the data " + "store to a later version using the `geowave util migrate` command.");
    } else if (storeVersion > DATA_VERSION) {
        throw new ParameterException("The data store '" + storeName + "' is using a newer serialization format.  Please update to a " + "newer version of the CLI that is compatible with the data store.");
    }
}
Also used : DataStoreOperations(org.locationtech.geowave.core.store.operations.DataStoreOperations) DataStoreProperty(org.locationtech.geowave.core.store.DataStoreProperty) ParameterException(com.beust.jcommander.ParameterException) IndexDimensionHint(org.locationtech.geowave.core.index.IndexDimensionHint) PropertyStore(org.locationtech.geowave.core.store.PropertyStore)

Aggregations

ParameterException (com.beust.jcommander.ParameterException)2 DataStoreProperty (org.locationtech.geowave.core.store.DataStoreProperty)2 PropertyStore (org.locationtech.geowave.core.store.PropertyStore)2 DataStoreOperations (org.locationtech.geowave.core.store.operations.DataStoreOperations)2 IOException (java.io.IOException)1 IndexDimensionHint (org.locationtech.geowave.core.index.IndexDimensionHint)1 DataStorePluginOptions (org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions)1 StoreLoader (org.locationtech.geowave.core.store.cli.store.StoreLoader)1