コード例 #1
0
ファイル: LogManager.java プロジェクト: amoudi87/asterixdb
 @Override
 public Boolean call() {
   synchronized (isStarted) {
     isStarted.set(true);
     isStarted.notify();
   }
   try {
     while (true) {
       flushPage = null;
       try {
         flushPage = flushQ.take();
         if (flushPage == POISON_PILL || terminateFlag.get()) {
           return true;
         }
       } catch (InterruptedException e) {
         if (flushPage == null) {
           continue;
         }
       }
       flushPage.flush();
       emptyQ.offer(flushPage);
     }
   } catch (Exception e) {
     if (LOGGER.isLoggable(Level.INFO)) {
       LOGGER.info("-------------------------------------------------------------------------");
       LOGGER.info("LogFlusher is terminating abnormally. System is in unusalbe state.");
       LOGGER.info("-------------------------------------------------------------------------");
     }
     e.printStackTrace();
     throw e;
   }
 }
コード例 #2
0
 void syncWithMockAppLauncher(
     boolean allowScheduling, AtomicBoolean mockAppLauncherGoFlag, MockTezClient tezClient)
     throws Exception {
   synchronized (mockAppLauncherGoFlag) {
     while (!mockAppLauncherGoFlag.get()) {
       mockAppLauncherGoFlag.wait();
     }
     mockApp = tezClient.getLocalClient().getMockApp();
     mockLauncher = mockApp.getContainerLauncher();
     mockLauncher.startScheduling(allowScheduling);
     mockAppLauncherGoFlag.notify();
   }
 }
コード例 #3
0
  private void startServer(final InetSocketAddress serverAddress) throws Exception {
    this.m_dataServerSocket = new ServerSocket(serverAddress.getPort());
    synchronized (m_dataServerStarted) {
      m_dataServerStarted.set(true);
      m_dataServerStarted.notify();
    }

    while (!this.m_dataServerSocket.isClosed()) {
      final Socket client;
      try {
        client = m_dataServerSocket.accept();
        m_dataServerSockets.incrementAndGet();
        synchronized (m_dataServerSockets) {
          m_dataServerSockets.notify();
        }
      } catch (final SocketException se) {
        m_log.debug("Socket closed");
        assertTrue(m_stopDataServer.get());
        // This will happen when the server socket's closed.
        break;
      }
      m_log.debug("Got data socket number: " + m_dataServerSockets);
      final Runnable serverSocketRunner =
          new Runnable() {
            public void run() {
              try {
                serveDataSocket(client);
              } catch (final Throwable t) {
                m_socketServingFailed.set(true);
              }
            }
          };
      final Thread serverSocketThread =
          new Thread(serverSocketRunner, "Server-Socket-Serving-Thread");
      serverSocketThread.setDaemon(true);
      serverSocketThread.start();
    }
  }