Package com.netflix.exhibitor.core.state

Examples of com.netflix.exhibitor.core.state.ServerSpec


public class TestServerSpec
{
    @Test
    public void testSpecString()
    {
        ServerSpec      s1 = new ServerSpec("host", 1, ServerType.STANDARD);
        ServerSpec      s2 = new ServerSpec("host", 2, ServerType.OBSERVER);

        Assert.assertEquals(s1.toSpecString(), "1:host");
        Assert.assertEquals(s2.toSpecString(), "O:2:host");
    }
View Full Code Here


    {
        InstanceConfig              config = context.getExhibitor().getConfigManager().getConfig();

        String                      response = new FourLetterWord(FourLetterWord.Word.RUOK, config, context.getExhibitor().getConnectionTimeOutMs()).getResponse();
        ServerList                  serverList = new ServerList(config.getString(StringConfigs.SERVERS_SPEC));
        ServerSpec                  us = Iterables.find(serverList.getSpecs(), ServerList.isUs(context.getExhibitor().getThisJVMHostname()), null);

        ObjectNode                  mainNode = JsonNodeFactory.instance.objectNode();
        ObjectNode                  configNode = JsonNodeFactory.instance.objectNode();
        ObjectNode                  controlPanelNode = JsonNodeFactory.instance.objectNode();

        mainNode.put("version", context.getExhibitor().getVersion());
        mainNode.put("running", "imok".equals(response));
        mainNode.put("backupActive", context.getExhibitor().getBackupManager().isActive());
        mainNode.put("standaloneMode", context.getExhibitor().getConfigManager().isStandaloneMode());
        mainNode.put("extraHeadingText", context.getExhibitor().getExtraHeadingText());
        mainNode.put("nodeMutationsAllowed", context.getExhibitor().nodeMutationsAllowed());

        configNode.put("rollInProgress", context.getExhibitor().getConfigManager().isRolling());
        configNode.put("rollStatus", context.getExhibitor().getConfigManager().getRollingConfigState().getRollingStatus());
        configNode.put("rollPercentDone", context.getExhibitor().getConfigManager().getRollingConfigState().getRollingPercentDone());

        configNode.put("hostname", context.getExhibitor().getThisJVMHostname());
        configNode.put("serverId", (us != null) ? us.getServerId() : -1);
        for ( StringConfigs c : StringConfigs.values() )
        {
            configNode.put(fixName(c), config.getString(c));
        }
        for ( IntConfigs c : IntConfigs.values() )
View Full Code Here

        int observerThreshold = exhibitor.getConfigManager().getConfig().getInt(IntConfigs.OBSERVER_THRESHOLD);
        ServerType serverType = ((observerThreshold > 0) && (standardTypeCount >= observerThreshold)) ? ServerType.OBSERVER : ServerType.STANDARD;

        int existingMaxId = FlexibleEnsembleBuilder.getExistingMaxId(configuredServerList);
        ServerSpec us = new ServerSpec(exhibitor.getThisJVMHostname(), existingMaxId + 1, serverType);
        newList.add(us);

        return new ServerList(newList);
    }
View Full Code Here

        ImmutableMap.Builder<ServerSpec, InstanceStateTypes> builder = ImmutableMap.builder();
        List<ServerStatus> currentStatuses = statuses.get();
        for ( ServerStatus status : currentStatuses )
        {
            ServerSpec spec = serverList.getSpec(status.getHostname());
            if ( spec != null )
            {
                builder.put(spec, status.getInstanceStateType());
            }
            else
View Full Code Here

        List<ServerSpec>        newList = Lists.newArrayList();

        Set<String> addedHostnames = Sets.newHashSet();
        for ( ServerStatus status : clusterState.getLiveInstances() )
        {
            ServerSpec spec = configuredServerList.getSpec(status.getHostname());
            if ( spec == null )
            {
                spec = new ServerSpec(status.getHostname(), ++existingMaxId, ServerType.STANDARD);
                addedHostnames.add(spec.getHostname());
            }
            newList.add(spec);
        }

        if ( usState.getUs() == null )
        {
            ServerSpec      spec = new ServerSpec(exhibitor.getThisJVMHostname(), ++existingMaxId, ServerType.STANDARD);
            addedHostnames.add(spec.getHostname());
            newList.add(spec);
        }

        int                 standardTypeCount = 0;
        for ( ServerSpec spec : newList )
        {
            if ( spec.getServerType() == ServerType.STANDARD )
            {
                ++standardTypeCount;
            }
        }

        int         observerThreshold = exhibitor.getConfigManager().getConfig().getInt(IntConfigs.OBSERVER_THRESHOLD);
        if ( observerThreshold > 0 )
        {
            for ( int i = 0; (standardTypeCount >= observerThreshold) && (i < newList.size()); ++i )
            {
                ServerSpec      spec = newList.get(i);
                if ( addedHostnames.contains(spec.getHostname()) )  // i.e. don't change existing instances to observer
                {
                    newList.set(i, new ServerSpec(spec.getHostname(), spec.getServerId(), ServerType.OBSERVER));
                    --standardTypeCount;
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.netflix.exhibitor.core.state.ServerSpec

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.