예제 #1
0
 public void publish(String key, String value) {
   logger.log(Level.INFO, "adding cache entry: " + key + " = " + value);
   try {
     if (cache == null) {
       cache = gms.getGroupHandle().getDistributedStateCache();
     }
     cache.addToCache(GROUP_NAME, gms.getInstanceName(), key, value);
     GroupHandle gh = gms.getGroupHandle();
     gh.sendMessage(CACHE_CHANGE, CACHE_CHANGE.getBytes());
   } catch (GMSException e) {
     logger.log(Level.SEVERE, "Error updating cache" + e);
   }
 }
예제 #2
0
 public void addObserver(Observer o) {
   logger.log(Level.INFO, "Registering for group notifications");
   gms.addActionFactory(new JoinNotificationActionFactoryImpl(this));
   gms.addActionFactory(new JoinedAndReadyNotificationActionFactoryImpl(this));
   gms.addActionFactory(new MessageActionFactoryImpl(this), CACHE_CHANGE);
   gms.addActionFactory(new FailureNotificationActionFactoryImpl(this));
   gms.addActionFactory(new FailureSuspectedActionFactoryImpl(this));
   gms.addActionFactory(new PlannedShutdownActionFactoryImpl(this));
   super.addObserver(o);
 }
예제 #3
0
  public void start(String serverName) {
    logger.log(Level.INFO, "Initializing Shoal for with server name: " + serverName);

    gms =
        (GroupManagementService)
            GMSFactory.startGMSModule(
                serverName, GROUP_NAME, GroupManagementService.MemberType.CORE, null);

    //        TODO: shutdown hook is not working in linux , fix
    //        Runtime.getRuntime().addShutdownHook(new Thread() {
    //            @Override
    //            public void run() {
    //                System.out.println("system shutting down....");
    //                gms.shutdown(GMSConstants.shutdownType.INSTANCE_SHUTDOWN);
    //            }
    //        });

    try {
      gms.join();
    } catch (GMSException e) {
      logger.log(Level.SEVERE, "Error joining group" + e);
    }
  }
예제 #4
0
 public List<String> getAgent() {
   return gms.getGroupHandle().getAllCurrentMembers();
 }
예제 #5
0
 public Map getCache() {
   if (cache == null) {
     cache = gms.getGroupHandle().getDistributedStateCache();
   }
   return cache.getAllCache();
 }