private void performMaintenance(Operation maint, Operation get, Throwable getEx) { if (getEx != null) { logWarning("Failure getting state: %s", getEx.toString()); maint.complete(); return; } if (!get.hasBody()) { maint.complete(); return; } if (getHost().isStopping()) { maint.complete(); return; } LoaderServiceState localState = get.getBody(LoaderServiceState.class); if (localState == null || localState.loaderType == null || localState.path == null) { maint.complete(); return; } loadServices(localState); maint.complete(); }
@Override public void handlePut(Operation put) { final LoaderServiceState newState = put.getBody(LoaderServiceState.class); if (newState.loaderType == null) { newState.loaderType = LoaderType.FILESYSTEM; } setState(put, newState); put.setBody(newState).complete(); }
@Override public void handleStart(Operation op) { if (op.hasBody()) { LoaderServiceState s = op.getBody(LoaderServiceState.class); if (s.loaderType == null) { s.loaderType = LoaderType.FILESYSTEM; } logFine("Initial path is %s", s.path); } super.setMaintenanceIntervalMicros(MAINTENANCE_INTERVAL_MICROS); op.complete(); }
@Override public void handlePatch(Operation patch) { // Get the current state. final LoaderServiceState currentState = getState(patch); final LoaderServiceState patchBody = patch.getBody(LoaderServiceState.class); if (patchBody.path != null) { currentState.path = patchBody.path; } if (patchBody.loaderType != null) { currentState.loaderType = patchBody.loaderType; } else { currentState.loaderType = LoaderType.FILESYSTEM; } if (patchBody.servicePackages != null) { currentState.servicePackages = patchBody.servicePackages; } // Update the state. patch.setBody(currentState).complete(); }