/** * Scan each required path in each of the workspaces. * * @param operation the scanning operation that is to be called for each workspace & path * combination; may not be null */ public void onEachPathInWorkspace(ScanOperation operation) { for (Map.Entry<String, PathToScan> entry : pathsToScanByWorkspace.entries()) { String workspaceName = entry.getKey(); PathToScan pathToScan = entry.getValue(); try { for (IndexingCallback callback : pathToScan) { try { callback.beforeIndexing(); } catch (RuntimeException e) { Logger.getLogger(getClass()) .error( e, JcrI18n.errorIndexing, pathToScan.path(), workspaceName, e.getMessage()); } } operation.scan(workspaceName, pathToScan.path()); } catch (RuntimeException e) { Logger.getLogger(getClass()) .error(e, JcrI18n.errorIndexing, pathToScan.path(), workspaceName, e.getMessage()); } finally { for (IndexingCallback callback : pathToScan) { try { callback.afterIndexing(); } catch (RuntimeException e) { Logger.getLogger(getClass()) .error( e, JcrI18n.errorIndexing, pathToScan.path(), workspaceName, e.getMessage()); } } } } }
@Override public String serializeOperation(Operation operation) throws SerializingMarshallingException { try { switch (operation.type()) { case InsertOperation.TYPE: { InsertOperation simpleOperation = (InsertOperation) operation; List<Object> operationAsList = new ArrayList<>(); operationAsList.add(simpleOperation.getClass().getName()); operationAsList.add(simpleOperation.table()); operationAsList.add(simpleOperation.key()); // TODO // operationAsList.add( simpleOperation.fields() ); return OBJECT_MAPPER.writeValueAsString(operationAsList); } case ReadOperation.TYPE: { ReadOperation simpleOperation = (ReadOperation) operation; List<Object> operationAsList = new ArrayList<>(); operationAsList.add(simpleOperation.getClass().getName()); operationAsList.add(simpleOperation.table()); operationAsList.add(simpleOperation.key()); operationAsList.add(simpleOperation.fields()); return OBJECT_MAPPER.writeValueAsString(operationAsList); } case UpdateOperation.TYPE: { UpdateOperation simpleOperation = (UpdateOperation) operation; List<Object> operationAsList = new ArrayList<>(); operationAsList.add(simpleOperation.getClass().getName()); operationAsList.add(simpleOperation.table()); operationAsList.add(simpleOperation.key()); // TODO // operationAsList.add( simpleOperation.fields() ); return OBJECT_MAPPER.writeValueAsString(operationAsList); } case ScanOperation.TYPE: { ScanOperation simpleOperation = (ScanOperation) operation; List<Object> operationAsList = new ArrayList<>(); operationAsList.add(simpleOperation.getClass().getName()); operationAsList.add(simpleOperation.table()); operationAsList.add(simpleOperation.startkey()); operationAsList.add(simpleOperation.recordCount()); operationAsList.add(simpleOperation.fields()); return OBJECT_MAPPER.writeValueAsString(operationAsList); } case ReadModifyWriteOperation.TYPE: { ReadModifyWriteOperation simpleOperation = (ReadModifyWriteOperation) operation; List<Object> operationAsList = new ArrayList<>(); operationAsList.add(simpleOperation.getClass().getName()); operationAsList.add(simpleOperation.table()); operationAsList.add(simpleOperation.key()); operationAsList.add(simpleOperation.fields()); // TODO // operationAsList.add( simpleOperation.values() ); return OBJECT_MAPPER.writeValueAsString(operationAsList); } default: { throw new SerializingMarshallingException( format( "Workload does not know how to serialize operation\nWorkload: %s\nOperation Type: " + "%s\nOperation: %s", getClass().getName(), operation.getClass().getName(), operation)); } } } catch (IOException e) { throw new SerializingMarshallingException( format("Error serializing operation\n%s", operation), e); } }