Package com.netflix.exhibitor.core.entities

Examples of com.netflix.exhibitor.core.entities.ServerStatus


    private ServerStatus getStatus(ServerSpec spec)
    {
        if ( spec.equals(us) )
        {
            InstanceStateTypes state = exhibitor.getMonitorRunningInstance().getCurrentInstanceState();
            return new ServerStatus(spec.getHostname(), state.getCode(), state.getDescription(), exhibitor.getMonitorRunningInstance().isCurrentlyLeader());
        }

        try
        {
            RemoteInstanceRequest           request = new RemoteInstanceRequest(exhibitor, spec.getHostname());
            RemoteInstanceRequest.Result    result = request.makeRequest(exhibitor.getRemoteInstanceRequestClient(), "getStatus");

            ObjectMapper                    mapper = new ObjectMapper();
            JsonNode                        value = mapper.readTree(mapper.getJsonFactory().createJsonParser(result.remoteResponse));
            if ( value.size() == 0 )
            {
                return new ServerStatus(spec.getHostname(), InstanceStateTypes.DOWN.getCode(), InstanceStateTypes.DOWN.getDescription(), false);
            }

            int                             code = value.get("state").getValueAsInt();
            String                          description = value.get("description").getTextValue();
            return new ServerStatus(spec.getHostname(), code, description, value.get("isLeader").getBooleanValue());
        }
        catch ( IOException e )
        {
            log.error("Getting remote server status", e);
            throw new RuntimeException(e);
View Full Code Here


        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES, 1);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 100000);

        List<ServerStatus>          statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.SERVING.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.SERVING.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.SERVING.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);

        final AtomicBoolean         configWasChanged = new AtomicBoolean(false);
        AutomaticInstanceManagement management = new AutomaticInstanceManagement(mockExhibitorInstance.getMockExhibitor())
        {
            @Override
            void adjustConfig(String newSpec, String leaderHostname) throws Exception
            {
                super.adjustConfig(newSpec, leaderHostname);
                configWasChanged.set(true);
            }
        };
        management.call();

        Assert.assertFalse(configWasChanged.get()); // hasn't settled yet

        statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.DOWN.getCode(), "", false));
        statuses.add(new ServerStatus("b", InstanceStateTypes.SERVING.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.SERVING.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);

        management.call();

        Assert.assertFalse(configWasChanged.get());

        statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.SERVING.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.SERVING.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.SERVING.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 2000);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);

        management.call();
View Full Code Here

        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES, 1);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);

        List<ServerStatus>          statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.DOWN.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.DOWN.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.DOWN.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);

        final AtomicBoolean         configWasChanged = new AtomicBoolean(false);
        AutomaticInstanceManagement management = new AutomaticInstanceManagement(mockExhibitorInstance.getMockExhibitor())
        {
View Full Code Here

        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES, 1);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);

        List<ServerStatus>          statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.SERVING.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.SERVING.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.SERVING.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);

        final AtomicBoolean         configWasChanged = new AtomicBoolean(false);
        AutomaticInstanceManagement management = new AutomaticInstanceManagement(mockExhibitorInstance.getMockExhibitor())
        {
View Full Code Here

        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES, 1);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);

        List<ServerStatus>          statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.SERVING.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.DOWN.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.SERVING.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);

        AutomaticInstanceManagement management = new AutomaticInstanceManagement(mockExhibitorInstance.getMockExhibitor());
        management.call();
View Full Code Here

        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES, 1);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);

        List<ServerStatus>          statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.SERVING.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.SERVING.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.SERVING.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);

        AutomaticInstanceManagement management = new AutomaticInstanceManagement(mockExhibitorInstance.getMockExhibitor());
        management.call();
View Full Code Here

        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES, 1);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);

        List<ServerStatus>          statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.SERVING.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.SERVING.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.SERVING.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);

        AutomaticInstanceManagement management = new AutomaticInstanceManagement(mockExhibitorInstance.getMockExhibitor());
        LoadedInstanceConfig        loadedInstanceConfig = mockExhibitorInstance.getMockExhibitor().getConfigManager().getLoadedInstanceConfig();
        LoadedInstanceConfig        changedCoadedInstanceConfig = new LoadedInstanceConfig(loadedInstanceConfig.getConfig(), loadedInstanceConfig.getVersion() + 1);
View Full Code Here

        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES, 1);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);

        List<ServerStatus>          statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.SERVING.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.SERVING.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.DOWN.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);

        AutomaticInstanceManagement management = new AutomaticInstanceManagement(mockExhibitorInstance.getMockExhibitor());
        management.call();
View Full Code Here

        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 0);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.OBSERVER_THRESHOLD, 3);

        List<ServerStatus>          statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.SERVING.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.SERVING.getCode(), "", false));
        statuses.add(new ServerStatus("c", InstanceStateTypes.SERVING.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);

        AutomaticInstanceManagement management = new AutomaticInstanceManagement(mockExhibitorInstance.getMockExhibitor());
        management.call();
View Full Code Here

        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES, 1);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_FIXED_ENSEMBLE_SIZE, 3);
        mockExhibitorInstance.getMockConfigProvider().setConfig(IntConfigs.AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS, 0);

        List<ServerStatus> statuses = Lists.newArrayList();
        statuses.add(new ServerStatus("a", InstanceStateTypes.SERVING.getCode(), "", true));
        statuses.add(new ServerStatus("b", InstanceStateTypes.SERVING.getCode(), "", false));
        Mockito.when(mockExhibitorInstance.getMockForkJoinPool().invoke(Mockito.isA(ClusterStatusTask.class))).thenReturn(statuses);

        final AtomicBoolean configWasChanged = new AtomicBoolean(false);
        AutomaticInstanceManagement management = new AutomaticInstanceManagement(mockExhibitorInstance.getMockExhibitor())
        {
View Full Code Here

TOP

Related Classes of com.netflix.exhibitor.core.entities.ServerStatus

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.