@Override public void deleteSubnet(String subnetId) { getEntity().sensors().get(SdnAgent.DOCKER_HOST).runDockerCommand( String.format("network rm %s", subnetId)); }
private String getConfigOrDefault(BasicAttributeSensorAndConfigKey<String> key, String def) { String val = entity.getConfig(key); if (Strings.isEmpty(val)) { val = entity.sensors().get(key); if (Strings.isEmpty(val)) { val = def; log.debug(entity + " has no config specified for " + key + "; using default `" + def + "`"); entity.sensors().set(key, val); } } return val; }
private void publishIsBusy() { final boolean busy = isBusy(); LOG.trace("{} taskCount={}, isBusy={}", new Object[]{this, getTaskCounter().get(), busy}); AttributeSensor<Boolean> sensor = Sensors.newBooleanSensor(getIsBusySensorName()); entity.sensors().set(sensor, busy); }
@Override public void onEvent(SensorEvent<T> event) { values.addLast(event.getValue()); pruneValues(); entity.sensors().set((AttributeSensor<Double>)target, getAverage()); }
@Override public void onEvent(SensorEvent<T> event) { Number current = elvis(event.getValue(), 0); double newVal = current.doubleValue() - last.doubleValue(); entity.sensors().set((AttributeSensor<T>)target, TypeCoercions.coerce(newVal, target.getTypeToken())); last = current; } }
@Override public void install() { events.add("install"); entity.sensors().set(SoftwareProcess.SERVICE_STATE_ACTUAL, Lifecycle.STARTING); }
@Override public void stop() { events.add("stop"); launched = false; entity.sensors().set(Startable.SERVICE_UP, false); }
protected void onReplacementFailed(String msg) { LOG.warn("ServiceReplacer failed for "+entity+": "+msg); consecutiveReplacementFailureTimes.add(currentTimeMillis()); if (getConfig(SET_ON_FIRE_ON_FAILURE)) { ServiceProblemsLogic.updateProblemsIndicator(entity, "ServiceReplacer", "replacement failed: "+msg); } entity.sensors().emit(ENTITY_REPLACEMENT_FAILED, new FailureDescriptor(entity, msg)); } }
public String getBindAddress() { String host = Optional.fromNullable(getEntity().config().get(HAProxyController.BIND_ADDRESS)).or("*"); Integer port = getEntity().sensors().get(HAProxyController.PROXY_HTTP_PORT); return host + ":" + port; }
@Override public void kill() { events.add("kill"); launched = false; entity.sensors().set(Startable.SERVICE_UP, false); }
public void setExpandedInstallDir(String val) { String oldVal = getEntity().getAttribute(SoftwareProcess.EXPANDED_INSTALL_DIR); if (Strings.isNonBlank(oldVal) && !oldVal.equals(val)) { log.info("Resetting expandedInstallDir (to "+val+" from "+oldVal+") for "+getEntity()); } expandedInstallDir = val; getEntity().sensors().set(SoftwareProcess.EXPANDED_INSTALL_DIR, val); }
@Override public void apply(EntityLocal entity) { super.apply(entity); String password = acceptableChars == null ? Identifiers.makeRandomPassword(passwordLength) : Identifiers.makeRandomPassword(passwordLength, acceptableChars); entity.sensors().set(sensor, password); } }
@Override public void start() { WinRmMachineLocation machine = (WinRmMachineLocation) location; Integer port = entity.getConfig(WinRmTool.PROP_PORT); UserAndHostAndPort winrmAddress = UserAndHostAndPort.fromParts(machine.getUser(), machine.getAddress().getHostName(), Optional.fromNullable(port)); getEntity().sensors().set(Attributes.WINRM_ADDRESS, winrmAddress); super.start(); }
@Override public void start() { WinRmMachineLocation machine = (WinRmMachineLocation) location; UserAndHostAndPort winrmAddress = UserAndHostAndPort.fromParts(machine.getUser(), machine.getAddress().getHostName(), entity.getAttribute(VanillaWindowsProcess.WINRM_PORT)); getEntity().sensors().set(Attributes.WINRM_ADDRESS, winrmAddress); super.start(); }
@Override public void launch() { entity.sensors().set(MySqlNode.PID_FILE, getRunDir() + "/" + AbstractSoftwareProcessSshDriver.PID_FILENAME); newScript(MutableMap.of("usePidFile", true), LAUNCHING) .updateTaskAndFailOnNonZeroResultCode() .body.append(format("nohup %s/bin/mysqld --defaults-file=%s --user=`whoami` > %s 2>&1 < /dev/null &", getBaseDir(), getConfigFile(), getLogFile())) .execute(); }
@Override public void onEvent(SensorEvent<Object> event) { final Effector<?> eff = getEffectorNamed(getConfig(EFFECTOR)).get(); if (isBusySensorEnabled()) { final Object currentSensorValue = entity.sensors().get(sensor); setMoreUpdatesComing(event.getTimestamp(), event.getValue(), currentSensorValue); } invoke(eff, MutableMap.<String, Object>of()); }