当前位置: 首页>>代码示例>>Java>>正文


Java AbstractIdleService类代码示例

本文整理汇总了Java中com.google.common.util.concurrent.AbstractIdleService的典型用法代码示例。如果您正苦于以下问题:Java AbstractIdleService类的具体用法?Java AbstractIdleService怎么用?Java AbstractIdleService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractIdleService类属于com.google.common.util.concurrent包,在下文中一共展示了AbstractIdleService类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: YarnTwillRunnerService

import com.google.common.util.concurrent.AbstractIdleService; //导入依赖的package包/类
/**
 * Creates an instance.
 *
 * @param config Configuration of the yarn cluster
 * @param zkConnect ZooKeeper connection string
 * @param locationFactory Factory to create {@link Location} instances that are readable and writable by this service
 */
public YarnTwillRunnerService(YarnConfiguration config, String zkConnect, LocationFactory locationFactory) {
  this.yarnConfig = config;
  this.locationFactory = locationFactory;
  this.zkClientService = getZKClientService(zkConnect);
  this.controllers = HashBasedTable.create();
  this.serviceDelegate = new AbstractIdleService() {
    @Override
    protected void startUp() throws Exception {
      YarnTwillRunnerService.this.startUp();
    }

    @Override
    protected void shutDown() throws Exception {
      YarnTwillRunnerService.this.shutDown();
    }
  };
}
 
开发者ID:apache,项目名称:twill,代码行数:25,代码来源:YarnTwillRunnerService.java

示例2: start

import com.google.common.util.concurrent.AbstractIdleService; //导入依赖的package包/类
@Override
public void start(Stage stage) {
  restartableService = new AutoRestartingService<>(() -> new AbstractIdleService() {
    @Override
    protected void startUp() {
      /* no-op */
    }

    @Override
    protected void shutDown() {
      /* no-op */
    }
  }, ServiceRestartPolicy.IMMEDIATE);
  startStoppableButton = new StartStoppableButton(restartableService);
  Scene scene = new Scene(startStoppableButton, 800, 600);
  stage.setScene(scene);
  stage.show();
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:19,代码来源:StartStoppableButtonTest.java

示例3: setUp

import com.google.common.util.concurrent.AbstractIdleService; //导入依赖的package包/类
@Before
public void setUp() {
    /*
     * Multiple things in AbstractIdleService and ServiceManager are final, necessitating indirect methods of seeing
     * if the service has been started up or shut down.
     */
    Service service = new AbstractIdleService() {
        @Override
        protected void startUp() throws Exception {
            logger.info("startUp");
        }

        @Override
        protected void shutDown() throws Exception {
            logger.info("shutDown");
        }

        @Override
        protected Executor executor() {
            return MoreExecutors.sameThreadExecutor();
        }
    };

    serviceManager = new ServiceManager(ImmutableSet.of(service));

    when(curatorManagementService.startAsync()).thenReturn(curatorManagementService);
    when(curatorManagementService.stopAsync()).thenReturn(curatorManagementService);

    startStopManager = new DefaultCultivarStartStopManager(curatorManagementService, serviceManager);
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:31,代码来源:DefaultCultivarStartStopManagerTest.java

示例4: testMultipleLeaders

import com.google.common.util.concurrent.AbstractIdleService; //导入依赖的package包/类
/** Test starting multiple instances that compete for leadership. */
@Test
public void testMultipleLeaders() throws Exception {
    final Trigger started = new Trigger();
    final AtomicInteger startCount = new AtomicInteger();
    for (int i = 0; i < 5; i++) {
        newLeaderService(1, TimeUnit.HOURS, new Supplier<Service>() {
            @Override
            public Service get() {
                return new AbstractIdleService() {
                    @Override
                    protected void startUp() throws Exception {
                        started.fire();
                        startCount.incrementAndGet();
                    }

                    @Override
                    protected void shutDown() throws Exception {
                        // Do nothing
                    }
                };
            }
        }).startAsync();
    }
    assertTrue(started.firedWithin(1, TimeUnit.MINUTES));
    // We know one service has started.  Wait a little while and verify no more services are started.
    Thread.sleep(250);
    assertTrue(startCount.get() == 1);
}
 
开发者ID:bazaarvoice,项目名称:curator-extensions,代码行数:30,代码来源:LeaderServiceTest.java

示例5: setUp

import com.google.common.util.concurrent.AbstractIdleService; //导入依赖的package包/类
@Before
public void setUp() {
    /*
     * Multiple things in AbstractIdleService and ServiceManager are final, necessitating indirect methods of seeing
     * if the service has been started up or shut down.
     */
    Service service = new AbstractIdleService() {
        @Override
        protected void startUp() throws Exception {
            logger.info("startUp");

        }

        @Override
        protected void shutDown() throws Exception {
            logger.info("shutDown");
        }

        @Override
        protected Executor executor() {
            return MoreExecutors.directExecutor();
        }
    };

    Service extraService1 = new AbstractIdleService() {
        @Override
        protected void startUp() throws Exception {
            extraLogger1.info("startUp");

        }

        @Override
        protected void shutDown() throws Exception {
            extraLogger1.info("shutDown");
        }

        @Override
        protected Executor executor() {
            return MoreExecutors.directExecutor();
        }
    };

    Service extraService2 = new AbstractIdleService() {
        @Override
        protected void startUp() throws Exception {
            extraLogger2.info("startUp");

        }

        @Override
        protected void shutDown() throws Exception {
            extraLogger2.info("shutDown");
        }

        @Override
        protected Executor executor() {
            return MoreExecutors.directExecutor();
        }
    };

    serviceManager = new ServiceManager(ImmutableSet.of(service));

    extraServiceManager1 = new ServiceManager(ImmutableSet.of(extraService1));

    ServiceManager extraServiceManager2 = new ServiceManager(ImmutableSet.of(extraService2));

    when(curatorManagementService.startAsync()).thenReturn(curatorManagementService);
    when(curatorManagementService.stopAsync()).thenReturn(curatorManagementService);

    startStopManager = new DefaultCultivarStartStopManager(curatorManagementService, serviceManager,
            ImmutableSet.of(extraServiceManager1, extraServiceManager2));
}
 
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:73,代码来源:DefaultCultivarStartStopManagerTest.java


注:本文中的com.google.common.util.concurrent.AbstractIdleService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。