use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class ZookeeperStatusChecker method handler.
@Handler
public void handler(OpsTarget target, ZookeeperServer zookeeperServer) throws OpsException {
if (OpsContext.isConfigure() || OpsContext.isValidate()) {
int port = ZookeeperConstants.ZK_PUBLIC_PORT;
List<EndpointInfo> endpoints = EndpointInfo.findEndpoints(zookeeperServer.getTags(), port);
EndpointInfo endpoint = EndpointChooser.any().choose(endpoints);
if (endpoint == null) {
throw new OpsException("Cannot find endpoint for zookeeper");
}
InetSocketAddress socketAddress = endpoint.asSocketAddress();
{
ZookeeperResponse response;
try {
// IPV6 requires ipsec; use the IPV4 loopback instead
socketAddress = new InetSocketAddress(InetAddresses.forString("127.0.0.1"), socketAddress.getPort());
response = ZookeeperUtils.sendCommand(target, socketAddress, "ruok");
Deviations.assertEquals("imok", response.getRaw(), "Zookeeper ruok status");
} catch (OpsException e) {
Deviations.fail("Unable to connect to zookeeper", e);
}
}
{
ZookeeperResponse response;
try {
response = ZookeeperUtils.sendCommand(target, socketAddress, "srvr");
Map<String, String> responseMap = response.asMap();
String mode = responseMap.get("Mode");
Deviations.assertIn(Arrays.asList("follower", "leader"), mode, "Zookeeper mode");
} catch (OpsException e) {
Deviations.fail("Unable to connect to zookeeper", e);
}
}
}
}
use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class ScheduleController method handler.
@Handler
public void handler() throws OpsException {
if (OpsContext.isConfigure()) {
String key = model.getKey().getUrl();
PlatformLayerKey target = model.targetItem;
PlatformLayerEndpointInfo endpoint = platformLayer.getEndpointInfo(target);
JobSchedule schedule = model.schedule;
Action action = model.action;
actionScheduler.putJob(key, endpoint, schedule, target, action);
}
}
use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class SolrCore method handler.
@Handler
public void handler(OpsTarget target) throws OpsException {
SolrCoreHelpers helper = new SolrCoreHelpers(target, key);
if (OpsContext.isConfigure()) {
// TODO: only reload if changed??
SolrCoreStatus status0 = helper.getStatus();
helper.reload();
// TODO: It looks like reload is async; hopefully this check deals with that
SolrCoreStatus status1 = helper.getStatus();
while (true) {
String startTime0 = status0.getStartTime();
String startTime1 = status1.getStartTime();
if (!Objects.equal(startTime0, startTime1)) {
break;
}
OpsSystem.safeSleep(TimeSpan.ONE_SECOND);
}
}
}
use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class TomcatServerBootstrap method doOperation.
@Handler
public void doOperation(OpsTarget target) throws OpsException {
File webappsDir = new File("/var/lib/tomcat6/webapps");
target.mv(webappsDir, new File("/var/lib/tomcat6/webapps.default"));
target.mkdir(webappsDir, "775");
target.chown(webappsDir, "tomcat6", "tomcat6", false, false);
// We remove the root context, but we leave the ones relating to the manager app
File rootContext = new File("/etc/tomcat6/Catalina/localhost/ROOT.xml");
target.rm(rootContext);
// File contextsDir = new File("/etc/jetty/contexts");
// target.mv(contextsDir, new File("/etc/jetty/contexts.default"));
// target.mkdir(contextsDir, "755");
// target.chown(contextsDir, "root", "root", false);
}
use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class ApacheBootstrap method handler.
@Handler
public void handler() throws OpsException {
OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);
target.rm(new File("/etc/apache2/sites-enabled/000-default"));
}
Aggregations