Package com.netflix.exhibitor.core

Examples of com.netflix.exhibitor.core.Exhibitor


        {
            addRemoteAuth(builder, securityArguments.getRemoteAuthSpec());
        }

        builder.shutdownProc(makeShutdownProc(this));
        exhibitor = new Exhibitor(configProvider, null, backupProvider, builder.build());
        exhibitor.start();

        DefaultResourceConfig   application = JerseySupport.newApplicationConfig(new UIContext(exhibitor));
        ServletContainer        container = new ServletContainer(application);
        server = new Server(httpPort);
View Full Code Here


    private final DefaultResourceConfig     config;

    public ExhibitorResourceConfig(@Context ServletContext context)
    {
        DefaultResourceConfig   localConfig;
        Exhibitor               exhibitor = (Exhibitor)context.getAttribute(ExhibitorServletContextListener.class.getName());
        if ( exhibitor != null )
        {
            log.info("Adding Exhibitor Jersey resources");
            localConfig = JerseySupport.newApplicationConfig(new UIContext(exhibitor));
        }
View Full Code Here

        try
        {
            exhibitorCreator = new ExhibitorCreator(toArgsArray(argsBuilder));

            exhibitor = new Exhibitor(exhibitorCreator.getConfigProvider(), null, exhibitorCreator.getBackupProvider(), exhibitorCreator.getBuilder().build());
            exhibitor.start();

            event.getServletContext().setAttribute(ExhibitorServletContextListener.class.getName(), exhibitor);
        }
        catch ( MissingConfigurationTypeException exit )
View Full Code Here

        ActivityQueue activityQueue = new ActivityQueue();

        final Queue<AssertionError> exceptions = Queues.newConcurrentLinkedQueue();

        Exhibitor mockExhibitor1 = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS);
        Mockito.when(mockExhibitor1.getActivityQueue()).thenReturn(activityQueue);
        ConfigManager configManager1 = new TestConfigManager(mockExhibitor1, mockConfigProvider);
        Mockito.when(mockExhibitor1.getConfigManager()).thenReturn(configManager1);
        MonitorRunningInstance monitorRunningInstance1 = new MockMonitorRunningInstance(mockExhibitor1, providerConfig, "one", restartLatch, exceptions);
        Mockito.when(mockExhibitor1.getMonitorRunningInstance()).thenReturn(monitorRunningInstance1);
        Mockito.when(mockExhibitor1.getThisJVMHostname()).thenReturn("one");
        Mockito.when(mockExhibitor1.getProcessOperations()).thenReturn(mockOperations1);
        Mockito.when(mockExhibitor1.getControlPanelValues()).thenReturn(mockControlPanelValues);

        Exhibitor mockExhibitor2 = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS);
        Mockito.when(mockExhibitor2.getActivityQueue()).thenReturn(activityQueue);
        ConfigManager configManager2 = new TestConfigManager(mockExhibitor2, mockConfigProvider);
        Mockito.when(mockExhibitor2.getConfigManager()).thenReturn(configManager2);
        MonitorRunningInstance monitorRunningInstance2 = new MockMonitorRunningInstance(mockExhibitor2, providerConfig, "two", restartLatch, exceptions);
        Mockito.when(mockExhibitor2.getMonitorRunningInstance()).thenReturn(monitorRunningInstance2);
        Mockito.when(mockExhibitor2.getThisJVMHostname()).thenReturn("two");
        Mockito.when(mockExhibitor2.getProcessOperations()).thenReturn(mockOperations2);
        Mockito.when(mockExhibitor2.getControlPanelValues()).thenReturn(mockControlPanelValues);

        Exhibitor mockExhibitor3 = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS);
        Mockito.when(mockExhibitor3.getActivityQueue()).thenReturn(activityQueue);
        ConfigManager configManager3 = new TestConfigManager(mockExhibitor3, mockConfigProvider);
        Mockito.when(mockExhibitor3.getConfigManager()).thenReturn(configManager3);
        MonitorRunningInstance monitorRunningInstance3 = new MockMonitorRunningInstance(mockExhibitor3, providerConfig, "three", restartLatch, exceptions);
        Mockito.when(mockExhibitor3.getMonitorRunningInstance()).thenReturn(monitorRunningInstance3);
        Mockito.when(mockExhibitor3.getThisJVMHostname()).thenReturn("three");
        Mockito.when(mockExhibitor3.getProcessOperations()).thenReturn(mockOperations3);
        Mockito.when(mockExhibitor3.getControlPanelValues()).thenReturn(mockControlPanelValues);

        try
        {
            activityQueue.start();
View Full Code Here

        data.put(new PathAndMax("/r2", 1), Arrays.asList("p4-0001", "p1-0002"));
        data.put(new PathAndMax("/r3", 1), Arrays.asList("p2-0001", "p5-0002"));
        data.put(new PathAndMax("/r4", 1), Arrays.asList("p2-0001", "p3-0002"));
        data.put(new PathAndMax("/r5", 1), Arrays.asList("p3-0001", "p4-0002"));

        Exhibitor       mockExhibitor = Mockito.mock(Exhibitor.class);
        PathAnalyzer    pathAnalyzer = new PathAnalyzer(mockExhibitor, Lists.newArrayList(data.keySet()))
        {
            @Override
            protected List<String> getChildren(String path) throws Exception
            {
View Full Code Here

            }
        };

        ActivityLog         log = new ActivityLog(100);
        ActivityQueue       activityQueue = new ActivityQueue();
        Exhibitor           mockExhibitor = Mockito.mock(Exhibitor.class);
        MonitorRunningInstance mockMonitorRunningInstance = makeMockMonitorRunningInstance();
        Mockito.when(mockExhibitor.getMonitorRunningInstance()).thenReturn(mockMonitorRunningInstance);
        Mockito.when(mockExhibitor.getLog()).thenReturn(log);
        Mockito.when(mockExhibitor.getActivityQueue()).thenReturn(activityQueue);
        Mockito.when(mockExhibitor.getThisJVMHostname()).thenReturn("one");
        Mockito.when(mockExhibitor.getRemoteInstanceRequestClient()).thenReturn(mockClient);

        final AtomicLong    modified = new AtomicLong(1);
        ConfigProvider      provider = new ConfigProvider()
        {
            private volatile ConfigCollection      config = new PropertyBasedInstanceConfig(new Properties(), new Properties());

            @Override
            public void start() throws Exception
            {
            }

            @Override
            public void close() throws IOException
            {
            }

            @Override
            public LoadedInstanceConfig loadConfig() throws Exception
            {
                return new LoadedInstanceConfig(config, modified.get());
            }

            @Override
            public PseudoLock newPseudoLock() throws Exception
            {
                return null;
            }

            @Override
            public LoadedInstanceConfig storeConfig(ConfigCollection config, long compareVersion) throws Exception
            {
                this.config = config;
                modified.incrementAndGet();
                return loadConfig();
            }
        };

        InstanceState       state = new InstanceState(serverList, InstanceStateTypes.NOT_SERVING, new RestartSignificantConfig(null));

        final AtomicBoolean hasBeenCanceled = new AtomicBoolean(false);
        ConfigManager       manager = new ConfigManager(mockExhibitor, provider, 10)
        {
            @Override
            public synchronized void cancelRollingConfig(CancelMode mode) throws Exception
            {
                super.cancelRollingConfig(mode);
                hasBeenCanceled.set(true);
            }
        };
        manager.start();
        try
        {
            Properties                      properties = new Properties();
            properties.setProperty(PropertyBasedInstanceConfig.toName(StringConfigs.SERVERS_SPEC, PropertyBasedInstanceConfig.ROOT_PROPERTY_PREFIX), serverList.toSpecString());
            PropertyBasedInstanceConfig     config = new PropertyBasedInstanceConfig(properties, DefaultProperties.get(null));
            manager.startRollingConfig(config.getRootConfig(), null);

            String      hostname = manager.getRollingConfigState().getRollingHostNames().get(0);
            Assert.assertTrue(manager.isRolling());

            RollingReleaseState     rollingState = new RollingReleaseState(state, manager.getCollection());
            Assert.assertEquals(rollingState.getCurrentRollingHostname(), hostname);
            Assert.assertNull(manager.getRollingConfigAdvanceAttempt());

            Mockito.when(mockExhibitor.getThisJVMHostname()).thenReturn(hostname);

            for ( int i = 0; i < (ConfigManager.DEFAULT_MAX_ATTEMPTS - 1); ++i )
            {
                long                lastModified = modified.get();
                manager.checkRollingConfig(state);
View Full Code Here

            }
        };

        ActivityLog         log = new ActivityLog(100);
        ActivityQueue       activityQueue = new ActivityQueue();
        Exhibitor           mockExhibitor = Mockito.mock(Exhibitor.class);
        MonitorRunningInstance mockMonitorRunningInstance = makeMockMonitorRunningInstance();
        Mockito.when(mockExhibitor.getMonitorRunningInstance()).thenReturn(mockMonitorRunningInstance);
        Mockito.when(mockExhibitor.getLog()).thenReturn(log);
        Mockito.when(mockExhibitor.getActivityQueue()).thenReturn(activityQueue);
        Mockito.when(mockExhibitor.getThisJVMHostname()).thenReturn("one");
        Mockito.when(mockExhibitor.getRemoteInstanceRequestClient()).thenReturn(mockClient);

        ConfigProvider      provider = new ConfigWrapper(new AtomicLong(1));

        Properties                      properties = new Properties();
        properties.setProperty(PropertyBasedInstanceConfig.toName(StringConfigs.SERVERS_SPEC, PropertyBasedInstanceConfig.ROOT_PROPERTY_PREFIX), serverList.toSpecString());
View Full Code Here

            }
        };

        ActivityLog         log = new ActivityLog(100);
        ActivityQueue       activityQueue = new ActivityQueue();
        Exhibitor           mockExhibitor = Mockito.mock(Exhibitor.class);
        MonitorRunningInstance mockMonitorRunningInstance = makeMockMonitorRunningInstance();
        Mockito.when(mockExhibitor.getMonitorRunningInstance()).thenReturn(mockMonitorRunningInstance);
        Mockito.when(mockExhibitor.getLog()).thenReturn(log);
        Mockito.when(mockExhibitor.getActivityQueue()).thenReturn(activityQueue);
        Mockito.when(mockExhibitor.getThisJVMHostname()).thenReturn("_xxxx_");
        Mockito.when(mockExhibitor.getRemoteInstanceRequestClient()).thenReturn(mockClient);

        ConfigProvider      provider = new ConfigWrapper(new AtomicLong(1));
        ConfigManager       manager = new ConfigManager(mockExhibitor, provider, 10, 1);
        manager.start();
        try
View Full Code Here

            }
        };

        ActivityLog         log = new ActivityLog(100);
        ActivityQueue       activityQueue = new ActivityQueue();
        Exhibitor           mockExhibitor = Mockito.mock(Exhibitor.class);
        MonitorRunningInstance mockMonitorRunningInstance = makeMockMonitorRunningInstance();
        Mockito.when(mockExhibitor.getMonitorRunningInstance()).thenReturn(mockMonitorRunningInstance);
        Mockito.when(mockExhibitor.getLog()).thenReturn(log);
        Mockito.when(mockExhibitor.getActivityQueue()).thenReturn(activityQueue);
        Mockito.when(mockExhibitor.getThisJVMHostname()).thenReturn("one");
        Mockito.when(mockExhibitor.getRemoteInstanceRequestClient()).thenReturn(mockClient);

        final AtomicLong    modified = new AtomicLong(1);
        ConfigProvider      provider = new ConfigWrapper(modified);

        InstanceState       state = new InstanceState(serverList, InstanceStateTypes.SERVING, new RestartSignificantConfig(null));

        ConfigManager       manager = new ConfigManager(mockExhibitor, provider, 10);
        manager.start();
        try
        {
            Properties                      properties = new Properties();
            properties.setProperty(PropertyBasedInstanceConfig.toName(StringConfigs.SERVERS_SPEC, PropertyBasedInstanceConfig.ROOT_PROPERTY_PREFIX), serverList.toSpecString());
            PropertyBasedInstanceConfig     config = new PropertyBasedInstanceConfig(properties, DefaultProperties.get(null));
            manager.startRollingConfig(config.getRootConfig(), null);

            for ( String hostname : manager.getRollingConfigState().getRollingHostNames() )
            {
                if ( hostname.equals("two") )
                {
                    continue;
                }

                Assert.assertTrue(manager.isRolling());

                RollingReleaseState     rollingState = new RollingReleaseState(state, manager.getCollection());
                Assert.assertEquals(rollingState.getCurrentRollingHostname(), hostname);

                Assert.assertNull(manager.getRollingConfigAdvanceAttempt());

                Mockito.when(mockExhibitor.getThisJVMHostname()).thenReturn(hostname);

                long                lastModified = modified.get();
                manager.checkRollingConfig(state);

                if ( hostname.equals("aaa") )     // the next will be the down instance "two"
View Full Code Here

            }
        };

        ActivityLog         log = new ActivityLog(100);
        ActivityQueue       activityQueue = new ActivityQueue();
        Exhibitor           mockExhibitor = Mockito.mock(Exhibitor.class);
        MonitorRunningInstance mockMonitorRunningInstance = makeMockMonitorRunningInstance();
        Mockito.when(mockExhibitor.getMonitorRunningInstance()).thenReturn(mockMonitorRunningInstance);
        Mockito.when(mockExhibitor.getLog()).thenReturn(log);
        Mockito.when(mockExhibitor.getActivityQueue()).thenReturn(activityQueue);
        Mockito.when(mockExhibitor.getThisJVMHostname()).thenReturn("one");
        Mockito.when(mockExhibitor.getRemoteInstanceRequestClient()).thenReturn(mockClient);

        final AtomicLong    modified = new AtomicLong(1);
        ConfigProvider      provider = new ConfigProvider()
        {
            private volatile ConfigCollection      config = new PropertyBasedInstanceConfig(new Properties(), new Properties());

            @Override
            public void start() throws Exception
            {
            }

            @Override
            public void close() throws IOException
            {
            }

            @Override
            public LoadedInstanceConfig loadConfig() throws Exception
            {
                return new LoadedInstanceConfig(config, modified.get());
            }

            @Override
            public PseudoLock newPseudoLock() throws Exception
            {
                return null;
            }

            @Override
            public LoadedInstanceConfig storeConfig(ConfigCollection config, long compareVersion) throws Exception
            {
                this.config = config;
                modified.incrementAndGet();
                return loadConfig();
            }
        };

        InstanceState       state = new InstanceState(serverList, InstanceStateTypes.SERVING, new RestartSignificantConfig(null));

        ConfigManager       manager = new ConfigManager(mockExhibitor, provider, 10);
        manager.start();
        try
        {
            Properties                      properties = new Properties();
            properties.setProperty(PropertyBasedInstanceConfig.toName(StringConfigs.SERVERS_SPEC, PropertyBasedInstanceConfig.ROOT_PROPERTY_PREFIX), serverList.toSpecString());
            PropertyBasedInstanceConfig     config = new PropertyBasedInstanceConfig(properties, DefaultProperties.get(null));
            manager.startRollingConfig(config.getRootConfig(), null);

            for ( String hostname : manager.getRollingConfigState().getRollingHostNames() )
            {
                if ( hostname.equals("two") )
                {
                    Assert.assertFalse(manager.isRolling());
                    continue;
                }

                Assert.assertTrue(manager.isRolling());

                RollingReleaseState     rollingState = new RollingReleaseState(state, manager.getCollection());
                Assert.assertEquals(rollingState.getCurrentRollingHostname(), hostname);

                Assert.assertNull(manager.getRollingConfigAdvanceAttempt());

                Mockito.when(mockExhibitor.getThisJVMHostname()).thenReturn(hostname);

                long                lastModified = modified.get();
                manager.checkRollingConfig(state);

                if ( hostname.equals("three") )     // the next will be the down instance "two"
View Full Code Here

TOP

Related Classes of com.netflix.exhibitor.core.Exhibitor

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.