/** * Start all services related to closures support. */ protected void startClosureServices(ServiceHost host, boolean startMockHostAdapterInstance) throws Throwable { host.log(Level.INFO, "Closure services starting..."); HostInitClosureServiceConfig.startServices(host, startMockHostAdapterInstance); host.log(Level.INFO, "Closure services started."); }
private static void handleQueryCompletion(ServiceHost host, Operation o, Throwable e) { if (e != null) { host.log(Level.SEVERE, "Query task failed: %s", Utils.toString(e)); return; } QueryTask queryTask = o.getBody(QueryTask.class); if (queryTask.results.documentLinks.isEmpty()) { host.log(Level.INFO, "Query returned no results"); return; } host.log(Level.INFO, "Returned query results: %s", Utils.toJsonHtml(queryTask.results)); }
private void handleFailure() { this.host.log(Level.WARNING, this.failureMessage); if (this.completion != null) { this.completion.handle(new IllegalStateException(this.failureMessage)); } return; }
private void executeRunnableSafe(Runnable task) { try { task.run(); } catch (Exception e) { log(Level.SEVERE, "Unhandled exception executing task: %s", Utils.toString(e)); } }
private void log(Level level, String fmt, Object... args) { if (taskConfiguration != null && taskConfiguration.getServiceHost() != null) { taskConfiguration.getServiceHost().log(level, fmt, args); } else { Logger.getLogger(getClass().getName()).log(level, fmt, args); } }
private void log(Level level, String fmt, Object... args) { if (taskConfiguration != null && taskConfiguration.getServiceHost() != null) { taskConfiguration.getServiceHost().log(level, fmt, args); } else { Logger.getLogger(getClass().getName()).log(level, fmt, args); } }
private void log(String message) { if (managementHost == null) { System.out.println(message); } else { managementHost.log(Level.WARNING, message); } } }
public void scheduleNodeGroupChangeMaintenance(String nodeSelectorPath) { long now = Utils.getNowMicrosUtc(); this.host.log(Level.FINE, "%s %d", nodeSelectorPath, now); this.synchronizationTimes.put(nodeSelectorPath, now); scheduleNodeGroupChangeMaintenance(nodeSelectorPath, null); }
private void cleanCache() { if (lastUsed + CACHED_DATA_MICROS < Utils.getSystemNowMicrosUtc()) { // expired, clean the reference cachedImages.clear(); lastUsed = 0; host.log(Level.INFO, "System image(s) removed from cache"); } else { // schedule next check host.schedule(this::cleanCache, CACHED_DATA_MICROS, TimeUnit.MICROSECONDS); } }
public static String getLocalUsersFile(ServiceHost host) { try { return PropertyUtils.getValue(host, LOCAL_USERS_FILE); } catch (Exception e) { host.log(Level.SEVERE, Utils.toString(e)); return null; } }
/** * Sets a metric with unit and value in the ServiceStat associated with the service */ public static void setStat(Service service, String name, String unit, double value) { service.getHost().log(Level.INFO, "Setting stat [service=%s] [name=%s] [unit=%s] [value=%f]", service.getClass(), name, unit, value); ServiceStats.ServiceStat stat = new ServiceStats.ServiceStat(); stat.name = name; stat.unit = unit; service.setStat(stat, value); }
@Override public void handlePost(Operation post) { if (services == null || services.isEmpty()) { getHost().log(Level.INFO, "No registered services for healthcheck found!"); post.complete(); return; } doHealthCheck(post); }
public void trackOperationForRetry(long expirationMicros, Throwable e, Operation op) { this.host.log(Level.WARNING, "Retrying id %d to %s (retries: %d). Failure: %s", op.getId(), op.getUri(), op.getRetryCount(), e.toString()); op.incrementRetryCount(); this.pendingOperationsForRetry.put(expirationMicros, op); }
private void handleUncaughtException(Service s, Operation op, Throwable e) { if (!Utils.isValidationError(e)) { log(Level.SEVERE, "Uncaught exception in service %s: %s", s.getUri(), Utils.toString(e)); } else if (this.logger.isLoggable(Level.FINE)) { log(Level.FINE, "Validation Error in service %s: %s", s.getUri(), Utils.toString(e)); } op.fail(e); }
private void sendResponse(ChannelHandlerContext ctx, Operation request, Integer streamId, String originalPath, double startTime) { try { applyRateLimit(ctx, request); writeResponseUnsafe(ctx, request, streamId, originalPath, startTime); } catch (Exception e1) { this.host.log(Level.SEVERE, "%s", Utils.toString(e1)); } }
private static Operation createOperation(Service service, ResourceOperationSpec spec) { service.getHost().log(Level.FINE, "Going to register Resource Operation name=%s, operation='%s'", spec.name, spec.operation); return Operation.createPost(service, ResourceOperationSpecService.FACTORY_LINK) .setBody(spec); }
void pauseChannel(Channel c) { NettyListenerChannelContext ctx = new NettyListenerChannelContext(); ctx.setChannel(c); this.host.log(Level.INFO, "Disabling auto-reads on %s", c); c.config().setAutoRead(false); ctx.updateLastUseTime(); this.pausedChannels.put(c.id().toString(), ctx); }
private void logTransactionConflict(Operation request, ServiceDocument currentState) { this.service .getHost() .log(Level.INFO, "Transaction %s conflicts on service %s: operation: %s, current state transaction: %s", request.getTransactionId(), this.service.getSelfLink(), request.getAction(), currentState.documentTransactionId); }
private void performIOMaintenance(Operation post, long now, MaintenanceStage nextStage, long deadline) { try { this.operationTracker.performMaintenance(now); performMaintenanceStage(post, nextStage, deadline); } catch (Exception e) { log(Level.WARNING, "Exception: %s", Utils.toString(e)); performMaintenanceStage(post, nextStage, deadline); } }
private void updateVolumeState(ContainerVolumeState patch) { sendRequest(Operation.createPatch(getHost(), patch.documentSelfLink) .setBody(patch) .setCompletion((o, e) -> { if (e != null) { getHost().log(Level.WARNING, "Could not update the component links of" + " volume %s", patch.name); } })); }