Search in sources :

Example 1 with RedisServer

use of org.platformlayer.service.redis.model.RedisServer in project platformlayer by platformlayer.

the class RedisServerController method addChildren.

@Override
protected void addChildren() throws OpsException {
    RedisServer model = OpsContext.get().getInstance(RedisServer.class);
    InstanceBuilder vm;
    {
        vm = InstanceBuilder.build(model.dnsName, this, model.getTags());
        // TODO: Memory _really_ needs to be configurable here!
        vm.publicPorts.add(PORT);
        vm.minimumMemoryMb = 1024;
        vm.hostPolicy.allowRunInContainer = true;
        addChild(vm);
    }
    vm.addChild(PackageDependency.build("redis-server"));
    RedisTemplateModel template = injected(RedisTemplateModel.class);
    vm.addChild(TemplatedFile.build(template, new File("/etc/redis/redis.conf")).setFileMode("444"));
    // Collectd not restarting correctly (doesn't appear to be hostname problems??)
    // instance.addChild(CollectdCollector.build());
    {
        PublicEndpoint endpoint = injected(PublicEndpoint.class);
        // endpoint.network = null;
        endpoint.publicPort = PORT;
        endpoint.backendPort = PORT;
        endpoint.dnsName = model.dnsName;
        endpoint.tagItem = model.getKey();
        endpoint.parentItem = model.getKey();
        vm.addChild(endpoint);
    }
    vm.addChild(ManagedService.build("redis-server"));
}
Also used : RedisServer(org.platformlayer.service.redis.model.RedisServer) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) TemplatedFile(org.platformlayer.ops.filesystem.TemplatedFile) File(java.io.File) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 2 with RedisServer

use of org.platformlayer.service.redis.model.RedisServer in project platformlayer by platformlayer.

the class ITRedisService method testCreateAndDeleteItem.

@Test
public void testCreateAndDeleteItem() throws Exception {
    String id = "redis" + random.randomAlphanumericString(8);
    RedisServer redis = new RedisServer();
    redis.dnsName = id + ".test.platformlayer.org";
    redis = putItem(id, redis);
    redis = waitForHealthy(redis);
    InetSocketAddress socketAddress = getUniqueEndpoint(redis);
    Assert.assertFalse(isPortOpen(socketAddress));
    openFirewall(redis, socketAddress.getPort());
    String info = testRedis(socketAddress);
    Assert.assertTrue(info.contains("redis_version:"));
}
Also used : InetSocketAddress(java.net.InetSocketAddress) RedisServer(org.platformlayer.service.redis.model.RedisServer) PlatformLayerApiTest(org.platformlayer.tests.PlatformLayerApiTest) Test(org.testng.annotations.Test)

Aggregations

RedisServer (org.platformlayer.service.redis.model.RedisServer)2 File (java.io.File)1 InetSocketAddress (java.net.InetSocketAddress)1 TemplatedFile (org.platformlayer.ops.filesystem.TemplatedFile)1 InstanceBuilder (org.platformlayer.ops.instances.InstanceBuilder)1 PublicEndpoint (org.platformlayer.ops.networks.PublicEndpoint)1 PlatformLayerApiTest (org.platformlayer.tests.PlatformLayerApiTest)1 Test (org.testng.annotations.Test)1