Package com.netflix.priam.identity

Examples of com.netflix.priam.identity.PriamInstance


    @Override
    public PriamInstance create(String app, int id, String instanceID, String hostname, String ip, String rac, Map<String, Object> volumes, String token)
    {
        try
        {
            PriamInstance ins = makePriamInstance(app, id, instanceID, hostname, ip, rac, volumes, token);
            // remove old data node which are dead.
            if (app.endsWith("-dead"))
            {
                try
                {
                    PriamInstance oldData = dao.getInstance(app, config.getDC(), id);
                    // clean up a very old data...
                    if (null != oldData && oldData.getUpdatetime() < (System.currentTimeMillis() - (3 * 60 * 1000)))
                        dao.deregisterInstance(oldData);
                }
                catch (Exception ex)
                {
                    //Do nothing
View Full Code Here


    }

    private PriamInstance makePriamInstance(String app, int id, String instanceID, String hostname, String ip, String rac, Map<String, Object> volumes, String token)
    {
        Map<String, Object> v = (volumes == null) ? new HashMap<String, Object>() : volumes;
        PriamInstance ins = new PriamInstance();
        ins.setApp(app);
        ins.setRac(rac);
        ins.setHost(hostname);
        ins.setHostIP(ip);
        ins.setId(id);
        ins.setInstanceId(instanceID);
        ins.setDC(config.getDC());
        ins.setToken(token);
        ins.setVolumes(v);
        return ins;
    }
View Full Code Here

     */
    @GET
    @Path("{id}")
    public String getInstance(@PathParam("id") int id)
    {
        PriamInstance node = getByIdIfFound(id);
        return node.toString();
    }
View Full Code Here

        @QueryParam("hostname") String hostname, @QueryParam("ip") String ip,
        @QueryParam("rack") String rack, @QueryParam("token") String token)
    {
        log.info("Creating instance [id={}, instanceId={}, hostname={}, ip={}, rack={}, token={}",
            new Object[]{ id, instanceID, hostname, ip, rack, token });
        PriamInstance instance = factory.create(config.getAppName(), id, instanceID, hostname, ip, rack, null, token);
        URI uri = UriBuilder.fromPath("/{id}").build(instance.getId());
        return Response.created(uri).build();
    }
View Full Code Here

     */
    @DELETE
    @Path("{id}")
    public Response deleteInstance(@PathParam("id") int id)
    {
        PriamInstance instance = getByIdIfFound(id);
        factory.delete(instance);
        return Response.noContent().build();
    }
View Full Code Here

     * @return PriamInstance with the given {@code id}
     * @throws WebApplicationException (400)
     */
    private PriamInstance getByIdIfFound(int id)
    {
        PriamInstance instance = factory.getInstance(config.getAppName(), config.getDC(), id);
        if (instance == null) {
            throw notFound(String.format("No priam instance with id %s found", id));
        }
        return instance;
    }
View Full Code Here

           
        }
       
        for (int i = 0; i < doubled.size(); i++)
        {
            PriamInstance ins = doubled.get(i);
            assertEquals(validator.get(i), ins.getToken());
            int id = ins.getId() - tokenManager.regionOffset(config.getDC());
            System.out.println(ins);
            if (0 != id % 2)
                assertEquals(ins.getInstanceId(), InstanceIdentity.DUMMY_INSTANCE_ID);
        }
    }
View Full Code Here

    }

    @Override
    public PriamInstance create(String app, int id, String instanceID, String hostname, String ip, String rac, Map<String, Object> volumes, String payload)
    {
        PriamInstance ins = new PriamInstance();
        ins.setApp(app);
        ins.setRac(rac);
        ins.setHost(hostname, ip);
        ins.setId(id);
        ins.setInstanceId(instanceID);
        ins.setToken(payload);
        ins.setVolumes(volumes);
        ins.setDC(config.getDC());
        instances.put(id, ins);
        return ins;
    }
View Full Code Here

     * @param item
     * @return
     */
    public PriamInstance transform(Item item)
    {
        PriamInstance ins = new PriamInstance();
        Iterator<Attribute> attrs = item.getAttributes().iterator();
        while (attrs.hasNext())
        {
            Attribute att = attrs.next();
            if (att.getName().equals(Attributes.INSTANCE_ID))
                ins.setInstanceId(att.getValue());
            else if (att.getName().equals(Attributes.TOKEN))
                ins.setToken(att.getValue());
            else if (att.getName().equals(Attributes.APP_ID))
                ins.setApp(att.getValue());
            else if (att.getName().equals(Attributes.ID))
                ins.setId(Integer.parseInt(att.getValue()));
            else if (att.getName().equals(Attributes.AVAILABILITY_ZONE))
                ins.setRac(att.getValue());
            else if (att.getName().equals(Attributes.ELASTIC_IP))
                ins.setHostIP(att.getValue());
            else if (att.getName().equals(Attributes.HOSTNAME))
                ins.setHost(att.getValue());
            else if (att.getName().equals(Attributes.LOCATION))
                ins.setDC(att.getValue());
            else if (att.getName().equals(Attributes.UPDATE_TS))
                ins.setUpdatetime(Long.parseLong(att.getValue()));
        }
        return ins;
    }
View Full Code Here

TOP

Related Classes of com.netflix.priam.identity.PriamInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.