Example #1
0
 @SuppressWarnings("WhileLoopSpinsOnField")
 @Override
 public void run() {
   try {
     while (running) {
       try {
         final JoinMessage joinMessage = receive();
         if (joinMessage != null) {
           for (MulticastListener multicastListener : listeners) {
             try {
               multicastListener.onMessage(joinMessage);
             } catch (Exception e) {
               logger.warning(e);
             }
           }
         }
       } catch (OutOfMemoryError e) {
         OutOfMemoryErrorDispatcher.onOutOfMemory(e);
       } catch (Exception e) {
         logger.warning(e);
       }
     }
   } finally {
     cleanup();
   }
 }
 private void handleException(Throwable e) {
   if (e instanceof OutOfMemoryError) {
     OutOfMemoryErrorDispatcher.onOutOfMemory((OutOfMemoryError) e);
     return;
   }
   if (e instanceof HazelcastSerializationException) {
     throw (HazelcastSerializationException) e;
   }
   throw new HazelcastSerializationException(e);
 }
  public static HazelcastInstance newHazelcastClient(ClientConfig config) {
    if (config == null) {
      config = new XmlClientConfigBuilder().build();
    }

    final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    HazelcastClientProxy proxy;
    try {
      Thread.currentThread().setContextClassLoader(HazelcastClient.class.getClassLoader());
      final HazelcastClient client = new HazelcastClient(config);
      client.start();
      OutOfMemoryErrorDispatcher.register(client);
      proxy = new HazelcastClientProxy(client);
      CLIENTS.put(client.id, proxy);
    } finally {
      Thread.currentThread().setContextClassLoader(tccl);
    }
    return proxy;
  }
Example #4
0
 @Override
 public void onOutOfMemory(OutOfMemoryError oom) {
   OutOfMemoryErrorDispatcher.onOutOfMemory(oom);
 }
 static {
   OutOfMemoryErrorDispatcher.setClientHandler(new ClientOutOfMemoryHandler());
 }