use of org.locationtech.geowave.datastore.hbase.server.ServerSideOperationStore in project geowave by locationtech.
the class ServerSideOperationsObserver method start.
@Override
public void start(final CoprocessorEnvironment env) throws IOException {
opStore = new ServerSideOperationStore();
final Configuration config = env.getConfiguration();
final Map<String, List<String>> uniqueOpsWithOptionKeys = new HashMap<>();
for (final Map.Entry<String, String> entry : config) {
if (entry.getKey().startsWith(ServerSideOperationUtils.SERVER_OP_PREFIX)) {
final String key = entry.getKey();
final int index = StringUtils.ordinalIndexOf(key, ".", 4);
if (index > 0) {
final String uniqueOp = key.substring(0, index + 1);
List<String> optionKeys = uniqueOpsWithOptionKeys.get(uniqueOp);
if (optionKeys == null) {
optionKeys = new ArrayList<>();
uniqueOpsWithOptionKeys.put(uniqueOp, optionKeys);
}
if (key.length() > (uniqueOp.length() + 1 + SERVER_OP_OPTIONS_PREFIX_LENGTH)) {
if (key.substring(uniqueOp.length(), uniqueOp.length() + SERVER_OP_OPTIONS_PREFIX_LENGTH).equals(ServerSideOperationUtils.SERVER_OP_OPTIONS_PREFIX)) {
optionKeys.add(key.substring(uniqueOp.length() + 1 + SERVER_OP_OPTIONS_PREFIX_LENGTH));
}
}
}
}
}
for (final Entry<String, List<String>> uniqueOpAndOptions : uniqueOpsWithOptionKeys.entrySet()) {
final String uniqueOp = uniqueOpAndOptions.getKey();
final String priorityStr = config.get(uniqueOp + ServerSideOperationUtils.SERVER_OP_PRIORITY_KEY);
if ((priorityStr == null) || priorityStr.isEmpty()) {
LOGGER.warn("Skipping server op - unable to find priority for '" + uniqueOp + "'");
continue;
}
final int priority = Integer.parseInt(priorityStr);
final String commaDelimitedScopes = config.get(uniqueOp + ServerSideOperationUtils.SERVER_OP_SCOPES_KEY);
if ((commaDelimitedScopes == null) || commaDelimitedScopes.isEmpty()) {
LOGGER.warn("Skipping server op - unable to find scopes for '" + uniqueOp + "'");
continue;
}
final ImmutableSet<ServerOpScope> scopes = HBaseUtils.stringToScopes(commaDelimitedScopes);
final String classIdStr = config.get(uniqueOp + ServerSideOperationUtils.SERVER_OP_CLASS_KEY);
if ((classIdStr == null) || classIdStr.isEmpty()) {
LOGGER.warn("Skipping server op - unable to find class ID for '" + uniqueOp + "'");
continue;
}
final List<String> optionKeys = uniqueOpAndOptions.getValue();
final Map<String, String> optionsMap = new HashMap<>();
for (final String optionKey : optionKeys) {
final String optionValue = config.get(uniqueOp + ServerSideOperationUtils.SERVER_OP_OPTIONS_PREFIX + "." + optionKey);
optionsMap.put(optionKey, optionValue);
}
final String[] uniqueOpSplit = uniqueOp.split("\\.");
opStore.addOperation(HBaseUtils.readConfigSafeTableName(uniqueOpSplit[1]), HBaseUtils.readConfigSafeTableName(uniqueOpSplit[2]), uniqueOpSplit[3], priority, scopes, ByteArrayUtils.byteArrayFromString(classIdStr), optionsMap);
}
RegionCoprocessor.super.start(env);
}
Aggregations