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!");
}
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.");
}
}
Aggregations