Search in sources :

Example 1 with ZookeeperServer

use of org.platformlayer.service.zookeeper.model.ZookeeperServer in project platformlayer by platformlayer.

the class ZookeeperInstance method addExtraFiles.

@Override
protected void addExtraFiles() throws OpsException {
    ZookeeperInstanceModel template = injected(ZookeeperInstanceModel.class);
    ZookeeperServer model = template.getModel();
    File instanceDir = template.getInstanceDir();
    addChild(ManagedDirectory.build(template.getDataDir(), "0755"));
    addChild(ManagedDirectory.build(template.getLogsDir(), "0755"));
    addChild(TemplatedFile.build(template, new File(template.getDataDir(), "myid")).setFileMode("0755"));
    addChild(SimpleFile.build(getClass(), new File(instanceDir, "log4j.properties")).setFileMode("0444"));
// addChild(SimpleFile.build(getClass(),
// new File(instanceDir, "start-zookeeper.sh"))
// .setFileMode("0555"));
// TODO: Monitor logs
// addChild(buildWatchLogFile(getInstanceDir().join("logs/zookeeper.log")));
// TODO: Add backup
// {
// BackupDirectory backup = injected(BackupDirectory.class);
// backup.itemKey = model.getKey();
//
// File jenkinsRoot = new File("/var/lib/jenkins");
// backup.backupRoot = jenkinsRoot;
//
// String[] excludes = { "jobs/*/workspace", "jobs/*/modules",
// "jobs/*/builds/*/workspace.tar.gz", ".m2/repository" };
//
// for (String exclude : excludes) {
// backup.excludes.add(new File(jenkinsRoot, exclude));
// }
//
// instance.addChild(backup);
// }
// We now use IPSEC...
// {
// for (ZookeeperServer peer : template.getClusterServers()) {
// if (Objects.equal(peer.getKey(), model.getKey())) {
// continue;
// }
//
// for (int systemPort : ZookeeperConstants.SYSTEM_PORTS) {
// NetworkConnection networkConnection = injected(NetworkConnection.class);
// networkConnection.setDestItem(peer.getKey());
// networkConnection.setSourceItem(model.getKey());
// networkConnection.setPort(systemPort);
// networkConnection.setProtocol("tcp");
//
// networkConnection.getTags().add(Tag.buildParentTag(model.getKey()));
// Tag uniqueTag = UniqueTag.build(model, peer, String.valueOf(systemPort));
// networkConnection.getTags().add(uniqueTag);
//
// String id = model.clusterId + "-" + peer.clusterId + "-" + systemPort;
// networkConnection.key = PlatformLayerKey.fromId(id);
//
// // Hmmm... when do we embed, and when do we not??
// // We need some clear rules!
// // Here, we don't embed because it's cross-machine
// platformLayer.putItemByTag(networkConnection, uniqueTag);
// }
// }
// }
}
Also used : ZookeeperServer(org.platformlayer.service.zookeeper.model.ZookeeperServer) SimpleFile(org.platformlayer.ops.filesystem.SimpleFile) TemplatedFile(org.platformlayer.ops.filesystem.TemplatedFile) File(java.io.File)

Example 2 with ZookeeperServer

use of org.platformlayer.service.zookeeper.model.ZookeeperServer in project platformlayer by platformlayer.

the class ZookeeperInstanceModel method getCluster.

public Cluster getCluster() throws OpsException {
    Cluster cluster = new Cluster();
    for (ZookeeperServer server : getClusterServers()) {
        // TODO: Do keys need to be sequential
        ClusterServer model = new ClusterServer();
        model.key = server.clusterId;
        // TODO: What do we do about machines that don't yet have an ip?
        NetworkPoint targetNetworkPoint = NetworkPoint.forPublicInternet();
        Machine sourceMachine = instances.getMachine(server);
        String address = sourceMachine.getNetworkPoint().getBestAddress(targetNetworkPoint);
        model.ip = address;
        model.dnsName = ZookeeperUtils.buildDnsName(server);
        cluster.servers.add(model);
    }
    return cluster;
}
Also used : ZookeeperServer(org.platformlayer.service.zookeeper.model.ZookeeperServer) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint) Machine(org.platformlayer.ops.Machine)

Example 3 with ZookeeperServer

use of org.platformlayer.service.zookeeper.model.ZookeeperServer in project platformlayer by platformlayer.

the class ZookeeperInstanceModel method getClusterServers.

public List<ZookeeperServer> getClusterServers() throws OpsException {
    PlatformLayerKey parent = getClusterKey();
    if (parent == null) {
        log.warn("Parent tag not set on Zookeeper server; assuming standalone server");
        return Lists.newArrayList(model);
    }
    List<ZookeeperServer> servers = platformLayer.listItems(ZookeeperServer.class, TagFilter.byTag(Tag.PARENT.build(parent)));
    return servers;
}
Also used : ZookeeperServer(org.platformlayer.service.zookeeper.model.ZookeeperServer) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Aggregations

ZookeeperServer (org.platformlayer.service.zookeeper.model.ZookeeperServer)3 File (java.io.File)1 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 Machine (org.platformlayer.ops.Machine)1 SimpleFile (org.platformlayer.ops.filesystem.SimpleFile)1 TemplatedFile (org.platformlayer.ops.filesystem.TemplatedFile)1 NetworkPoint (org.platformlayer.ops.networks.NetworkPoint)1