コード例 #1
0
  @Handler
  public void process() throws InterruptedException {

    LOG.info(
        "------------------------------------------------------------------------------------------------------------");
    LOG.info("Starting");

    /** Start the archive. */
    startMonitoringArchive();

    /** Start the navigation component. */
    startOrbitPredictor();

    Thread.sleep(1000);

    publishGroundStationsAndSatellites();
    publishTleParameters();

    List<String> locations = new ArrayList<String>();
    locations.add(es5ec.getID());
    locations.add(gsDarmstadt.getID());

    /** Create a controller task and inject it. */
    startEstcubeOrbitPropagator();

    Thread.sleep(20000);

    LOG.info("Finishing");
  }
コード例 #2
0
ファイル: ProfilerMain.java プロジェクト: mlhartme/jasmin
  private static void check(MimeType type, String str) throws Exception {
    References references;

    Node node = WORLD.getTemp().createTempFile();
    node.writeString(str);
    references = References.create(type, true, node);
    references.readBytes();
    node.deleteFile();

    System.gc();
    Thread.sleep(1000);

    System.out.println("Startup done");
    Thread.sleep(20000);
    System.out.println("computing ...");

    node = WORLD.getTemp().createTempFile();
    node.writeString(str);
    references = References.create(type, true, node);
    references.readBytes();
    node.deleteFile();

    System.out.println("busy wait to keep references");
    for (; ; ) ;
  }
コード例 #3
0
  @Test(priority = 2)
  public void AssignUpr() throws Exception {
    action.driver.navigate().refresh();
    // Click on tenant Management Link
    action.ClickLink(locator.getProperty("Tenant_Management"));
    action.WaitForTitle(locator.getProperty("Multi-Tenancy_Management"));
    action.VerifyTitle(locator.getProperty("Multi-Tenancy_Management"));
    action.SwithchFrame("iframe0");
    action.ClickElement(locator.getProperty("Tenanttree3"));
    Thread.sleep(1000);
    action.ClickLink(input.getProperty("site1"));
    action.ClickLink(locator.getProperty("User_Provisioning_Rule"));
    action.ClickButton(locator.getProperty("Tenantedit"));
    Thread.sleep(1000);
    // Select the Upr From table
    action.ClickButton(locator.getProperty("Tenantuprbtn0"));
    Thread.sleep(1000);
    // Click on Commit button
    action.ClickButton(locator.getProperty("Commit"));
    Thread.sleep(1000);

    action.WaitForTitle(locator.getProperty("Multi-Tenancy_Management"));
    action.VerifyTitle(locator.getProperty("Multi-Tenancy_Management"));
    Thread.sleep(2000);
    action.VerifyStringValue(
        "site1 is updated successfully. Refresh the tree to see updated node.");
  }
コード例 #4
0
ファイル: Aquarium.java プロジェクト: stuie382/Aquarium
 @Override
 public void run() {
   Rectangle edges =
       new Rectangle(
           0 + getInsets().left,
           0 + getInsets().top,
           getSize().width - (getInsets().left + getInsets().right),
           getSize().height - (getInsets().top + getInsets().bottom));
   for (int loopIndex = 0; loopIndex < numberFish; loopIndex++) {
     fishes[loopIndex] = new Fish(fishImages[0], fishImages[1], edges, this);
     try {
       Thread.sleep(20);
     } catch (Exception exp) {
       System.out.println(exp.getMessage());
     }
   }
   Fish fish;
   while (runOK) {
     for (int loopIndex = 0; loopIndex < numberFish; loopIndex++) {
       fish = fishes[loopIndex];
       fish.swim();
     }
     try {
       Thread.sleep(sleepTime);
     } catch (Exception exp) {
       System.out.println(exp.getMessage());
     }
     repaint();
   }
 }
コード例 #5
0
  public void testSearchUser() {
    NetworkDataManager ndm = new NetworkDataManager();
    User user = new User();
    User user2;
    user.setName("Connor");
    user.setUserAddress("1021");
    user.setUserName("ccdunn");
    user.setUserEmail("*****@*****.**");
    user.addFriend("gbullock");

    ndm.saveUser(user);

    try {
      Thread.sleep(500);
    } catch (Exception e) {
      e.printStackTrace();
    }

    assertTrue("Could not find the user", ndm.searchUser(user.getUserName()));

    assertFalse("Found a user that doesnt exist!", ndm.searchUser("NotExistingUser"));

    ndm.deleteUser(user.getUserName());

    try {
      Thread.sleep(500);
    } catch (Exception e) {
      e.printStackTrace();
    }

    assertFalse("Still finding user that should be deleted...", ndm.searchUser(user.getUserName()));
  }
コード例 #6
0
 public void waitUntilUnlocked(long timeToWaitBeforeVerify) throws InterruptedException {
   if (isLocked()) {
     long n = timeToWaitBeforeVerify / 100;
     for (int i = 0; i < n && isLocked(); i++) {
       if (isStateEnabled(UNLOCKED_BY_SOURCE_SESSION)) {
         // source session remote connection has been removed
         if (sourceSession
             .getCommandManager()
             .getTransportManager()
             .getConnectionsToExternalServices()
             .isEmpty()) {
           // the following line unlocks, unless UNLOCKED_BY_SOURCE_SESSION state is disabled
           unlock(UNLOCKED_BY_SOURCE_SESSION);
         }
       }
       if (isLocked()) {
         Thread.sleep(100);
       }
     }
     if (isLocked()) {
       unlock(UNLOCKED_BY_TIMER);
     } else if (state == UNLOCKED_BY_TARGET_LISTENER) {
       Thread.sleep(100);
     }
   }
 }
コード例 #7
0
  public void testPoolShrink() throws Exception {
    if (log.isDebugEnabled()) {
      log.debug("*** Starting testPoolShrink");
    }
    Field poolField = pds.getClass().getDeclaredField("pool");
    poolField.setAccessible(true);
    XAPool pool = (XAPool) poolField.get(pds);

    assertEquals(1, pool.inPoolSize());
    assertEquals(1, pool.totalPoolSize());

    Connection c1 = pds.getConnection();
    assertEquals(0, pool.inPoolSize());
    assertEquals(1, pool.totalPoolSize());

    Connection c2 = pds.getConnection();
    assertEquals(0, pool.inPoolSize());
    assertEquals(2, pool.totalPoolSize());

    c1.close();
    c2.close();

    Thread.sleep(1100); // leave enough time for the idle connections to expire
    TransactionManagerServices.getTaskScheduler().interrupt(); // wake up the task scheduler
    Thread.sleep(1200); // leave enough time for the scheduled shrinking task to do its work

    if (log.isDebugEnabled()) {
      log.debug("*** checking pool sizes");
    }
    assertEquals(1, pool.inPoolSize());
    assertEquals(1, pool.totalPoolSize());
  }
コード例 #8
0
    public void run() {
      try {
        if (myPreviousThread != null) myPreviousThread.join();
        Thread.sleep(delay);
        log("> run MouseMoveThread " + x + ", " + y);
        while (!hasFocus()) {
          Thread.sleep(1000);
        }
        int x1 = lastMouseX;
        int x2 = x;
        int y1 = lastMouseY;
        int y2 = y;
        // shrink range by 1 px on both ends
        // manually move this 1px to trip DND code
        if (x1 != x2) {
          int dx = x - lastMouseX;
          if (dx > 0) {
            x1 += 1;
            x2 -= 1;
          } else {
            x1 -= 1;
            x2 += 1;
          }
        }
        if (y1 != y2) {
          int dy = y - lastMouseY;
          if (dy > 0) {
            y1 += 1;
            y2 -= 1;
          } else {
            y1 -= 1;
            y2 += 1;
          }
        }
        robot.setAutoDelay(Math.max(duration / 100, 1));
        robot.mouseMove(x1, y1);
        int d = 100;
        for (int t = 0; t <= d; t++) {
          x1 =
              (int)
                  easeInOutQuad(
                      (double) t, (double) lastMouseX, (double) x2 - lastMouseX, (double) d);
          y1 =
              (int)
                  easeInOutQuad(
                      (double) t, (double) lastMouseY, (double) y2 - lastMouseY, (double) d);
          robot.mouseMove(x1, y1);
        }
        robot.mouseMove(x, y);
        lastMouseX = x;
        lastMouseY = y;
        robot.waitForIdle();
        robot.setAutoDelay(1);
      } catch (Exception e) {
        log("Bad parameters passed to mouseMove");
        e.printStackTrace();
      }

      log("< run MouseMoveThread");
    }
コード例 #9
0
  public static void main(String[] args) throws Exception {
    int maxThreads = 100;

    if (args.length > 0) maxThreads = Integer.parseInt(args[0]);

    System.out.print("Warmup:");
    for (int j = 0; j < 2; ++j) {
      int k = 1;
      for (int i = 1; i <= maxThreads; ) {
        System.out.print(" " + i);
        oneTest(i, 10000, false);
        Thread.sleep(100);
        if (i == k) {
          k = i << 1;
          i = i + (i >>> 1);
        } else i = k;
      }
    }
    System.out.println();

    int k = 1;
    for (int i = 1; i <= maxThreads; ) {
      System.out.println("Threads:" + i);
      oneTest(i, maxIters, true);
      Thread.sleep(100);
      if (i == k) {
        k = i << 1;
        i = i + (i >>> 1);
      } else i = k;
    }
  }
コード例 #10
0
ファイル: TokenThread.java プロジェクト: xieyunchaobest/hp
 public void run() {
   while (true) {
     try {
       accessToken = WeixinUtil.getAccessToken(appid, appsecret);
       if (null != accessToken) {
         log.info(
             "获取access_token成功,有效时长{}秒 token:{}==="
                 + accessToken.getExpiresIn()
                 + "    "
                 + accessToken.getToken());
         // 休眠7000秒
         Thread.sleep((accessToken.getExpiresIn() - 200) * 1000);
       } else {
         // 如果access_token为null,60秒后再获取
         Thread.sleep(60 * 1000);
       }
     } catch (InterruptedException e) {
       try {
         Thread.sleep(60 * 1000);
       } catch (InterruptedException e1) {
         log.error("{}", e1);
       }
       log.error("{}", e);
     }
   }
 }
コード例 #11
0
  public void testViewTasksTaskAssignedToMeTag() throws Exception {
    selenium.open("/user/joebloggs/so/dashboard/");

    for (int second = 0; ; second++) {
      if (second >= 90) {
        fail("timeout");
      }

      try {
        if (selenium.isVisible("//nav/ul/li[contains(.,'Tasks')]/a/span")) {
          break;
        }
      } catch (Exception e) {
      }

      Thread.sleep(1000);
    }

    selenium.clickAt("//nav/ul/li[contains(.,'Tasks')]/a/span", RuntimeVariables.replace("Tasks"));
    selenium.waitForPageToLoad("30000");
    assertEquals(
        RuntimeVariables.replace("Tasks"),
        selenium.getText("//span[@class='portlet-title-default']"));
    assertEquals(
        RuntimeVariables.replace("Assigned to Me"), selenium.getText("link=Assigned to Me"));
    selenium.clickAt("link=Assigned to Me", RuntimeVariables.replace("Assigned to Me"));
    selenium.waitForPageToLoad("30000");
    assertTrue(selenium.isVisible("//div[@class='tags-wrapper']"));
    assertEquals(
        RuntimeVariables.replace("Task Description"), selenium.getText("link=Task Description"));
    selenium.clickAt("link=Task Description", RuntimeVariables.replace("Task Description"));

    for (int second = 0; ; second++) {
      if (second >= 90) {
        fail("timeout");
      }

      try {
        if (RuntimeVariables.replace("Task Description")
            .equals(selenium.getText("//h1[@class='header-title']"))) {
          break;
        }
      } catch (Exception e) {
      }

      Thread.sleep(1000);
    }

    assertEquals(
        RuntimeVariables.replace("Task Description"),
        selenium.getText("//h1[@class='header-title']"));
    assertEquals(
        RuntimeVariables.replace("Assigned to Joe Bloggs"),
        selenium.getText("//div[@class='task-data assignee']"));
    assertEquals(
        RuntimeVariables.replace("Open"), selenium.getText("//div[@class='task-data status']"));
    assertEquals(
        RuntimeVariables.replace("Normal"), selenium.getText("//div[@class='task-data normal']"));
    assertEquals(RuntimeVariables.replace("tag1"), selenium.getText("//span[@class='tag']"));
  }
コード例 #12
0
  @RandomlyFails // NB-Core-Build #8241
  public void testTheStarvation37045() throws Exception {
    org.openide.util.Task task;

    synchronized (this) {
      org.openide.util.RequestProcessor.getDefault().post(support);
      // wait for the support (another thread) to try to open and block
      wait();

      // now post there another task
      task = org.openide.util.RequestProcessor.getDefault().post(support);
      // wait for it to block, any amount of time is likely to do it
      Thread.sleep(500);

      // notify the first edit(), to continue (and throw exception)
      notify();
    }

    // check for deadlock
    for (int i = 0; i < 5; i++) {
      if (task.isFinished()) break;
      Thread.sleep(500);
    }

    // uncomment the next line if you want to see real starvation threaddump
    // task.waitFinished ();
    assertTrue("Should be finished, but there is a starvation", task.isFinished());
  }
  /**
   * Non Regression test for http://code.google.com/p/mobicents/issues/detail?id=1837 ACK was
   * received by JAIN-SIP but was not routed to application
   */
  public void testCallForwardingCallerReInviteAckRaceInfo() throws Exception {
    sender = new TestSipListener(5080, 5070, senderProtocolObjects, false);
    SipProvider senderProvider = sender.createProvider();

    receiver = new TestSipListener(5090, 5070, receiverProtocolObjects, false);
    receiver.setDisableSequenceNumberValidation(true);
    SipProvider receiverProvider = receiver.createProvider();

    receiverProvider.addSipListener(receiver);
    senderProvider.addSipListener(sender);

    senderProtocolObjects.start();
    receiverProtocolObjects.start();

    String fromName = "forward-pending-sender";
    String fromSipAddress = "sip-servlets.com";
    SipURI fromAddress =
        senderProtocolObjects.addressFactory.createSipURI(fromName, fromSipAddress);

    String toSipAddress = "sip-servlets.com";
    String toUser = "******";
    SipURI toAddress = senderProtocolObjects.addressFactory.createSipURI(toUser, toSipAddress);

    sender.setTimeToWaitBeforeAck(9000);
    sender.sendSipRequest("INVITE", fromAddress, toAddress, null, null, false);
    Thread.sleep(8000);
    receiver.sendInDialogSipRequest("UPDATE", null, null, null, null, null);
    Thread.sleep(TIMEOUT);
    assertTrue(receiver.isAckReceived());
  }
コード例 #14
0
ファイル: DHTManagerTest.java プロジェクト: KenaDess/limewire
 public void testStopStartLimeDHTManager() throws Exception {
   TestExecutor executor = new TestExecutor();
   DHTManagerImpl manager = new DHTManagerImpl(executor, dhtControllerFactory);
   try {
     manager.start(DHTMode.ACTIVE);
     manager.stop();
     Thread.sleep(200);
     assertFalse(manager.isRunning());
     manager.start(DHTMode.ACTIVE);
     Thread.sleep(200);
     assertTrue(manager.isRunning());
     assertEquals(DHTMode.ACTIVE, manager.getDHTMode());
     manager.start(DHTMode.PASSIVE);
     Thread.sleep(200);
     assertEquals(DHTMode.PASSIVE, manager.getDHTMode());
     assertTrue(manager.isRunning());
     manager.start(DHTMode.ACTIVE);
     manager.start(DHTMode.PASSIVE);
     manager.start(DHTMode.ACTIVE);
     manager.stop();
     assertFalse(manager.isRunning());
     Thread.sleep(500);
     assertFalse(manager.isRunning());
   } finally {
     manager.stop();
   }
 }
コード例 #15
0
ファイル: BgMerge.java プロジェクト: beccaree/takoyaki
  /*
   * Combines audio input with video input at specified time
   * @see javax.swing.SwingWorker#doInBackground()
   */
  @Override
  protected Void doInBackground() throws Exception {

    // Extract the audio from the video and save it as a hidden file in MP3Files
    String cmd = "ffmpeg -y -i " + videoPath + " -map 0:1 ./MP3Files/.vidAudio.mp3";

    ProcessBuilder builder = new ProcessBuilder("/bin/bash", "-c", cmd);
    Process process = builder.start();
    process.waitFor();

    for (int i = 1; i < 25; i++) { // Update progress bar when above process is complete
      Thread.sleep(40);
      progress.updateProgress(i);
    }
    if (time == 0) {
      // Create a hidden mp3 file output.mp3 that combines the video audio and selected mp3 audio at
      // time 0
      cmd =
          "ffmpeg -y -i "
              + audioPath
              + " -i ./MP3Files/.vidAudio.mp3 -filter_complex amix=inputs=2 ./MP3Files/.output.mp3";
    } else {
      // Create a hidden mp3 file output.mp3 that combines the video audio and selected mp3 audio at
      // specified time
      cmd =
          "ffmpeg -y -i "
              + audioPath
              + " -i ./MP3Files/.vidAudio.mp3 -filter_complex \"[0:0]adelay="
              + time
              + "[aud1];[aud1][1:0]amix=inputs=2\" ./MP3Files/.output.mp3";
    }

    builder = new ProcessBuilder("/bin/bash", "-c", cmd);
    process = builder.start();
    process.waitFor();

    for (int i = 1; i < 50; i++) { // Update progress bar
      Thread.sleep(40);
      progress.updateProgress(25 + i);
    }

    // Creates an output.avi file from merging existing video stream (1:0) and combined audio (0:0)
    cmd =
        "ffmpeg -i "
            + videoPath
            + " -i ./MP3Files/.output.mp3 -map 0:0 -map 1:0 -acodec copy -vcodec copy ./VideoFiles/"
            + name
            + ".avi";

    builder = new ProcessBuilder("/bin/bash", "-c", cmd);
    process = builder.start();
    process.waitFor();

    for (int i = 1; i < 25; i++) { // Update progress bar
      Thread.sleep(40);
      progress.updateProgress(75 + i);
    }

    return null;
  }
コード例 #16
0
ファイル: AddService.java プロジェクト: rajddesai/odp
 @Test(dependsOnMethods = "customizeServices")
 public void review() throws InterruptedException {
   Thread.sleep(2000);
   System.out.println("review");
   WebElementHelper.findAndClickByID(driver, "spinner", 30, "Depoly");
   Thread.sleep(2000);
 }
コード例 #17
0
 public void run() {
   int temp = 0;
   System.out.println("Iniciar contador:");
   try {
     if (!Thread.interrupted()) {
       while (temp < 10) {
         System.out.println("Tiempo restante " + (10 - temp) + " segundos");
         Thread.sleep(1000);
         temp++;
       }
     }
   } catch (InterruptedException x) {
     if (temp > 5) {
       System.out.println("Interrumpido despues de 5 segundos, cerramos el programa");
     } else {
       System.out.println(
           "Interrumpido antes de 5 segundos, el programa se cerrará en 10 segundos");
       try {
         Thread.sleep(10000);
       } catch (InterruptedException e) {
       }
       System.out.println("Fin 10 segundos");
     }
     return;
   }
   System.out.println("Finalizado");
 }
コード例 #18
0
  @Test
  public void TestControllerChange() throws Exception {
    String controllerName = CONTROLLER_PREFIX + "_0";
    _controller.syncStop();

    Thread.sleep(1000);

    // kill controller, participant should not know about the svc url
    for (int i = 0; i < NODE_NR; i++) {
      HelixDataAccessor accessor = _participants[i].getHelixDataAccessor();
      ZKHelixDataAccessor zkAccessor = (ZKHelixDataAccessor) accessor;
      Assert.assertTrue(
          zkAccessor._zkPropertyTransferSvcUrl == null
              || zkAccessor._zkPropertyTransferSvcUrl.equals(""));
    }

    _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
    _controller.syncStart();

    Thread.sleep(1000);

    // create controller again, the svc url is notified to the participants
    for (int i = 0; i < NODE_NR; i++) {
      HelixDataAccessor accessor = _participants[i].getHelixDataAccessor();
      ZKHelixDataAccessor zkAccessor = (ZKHelixDataAccessor) accessor;
      Assert.assertTrue(
          zkAccessor._zkPropertyTransferSvcUrl.equals(
              ZKPropertyTransferServer.getInstance().getWebserviceUrl()));
    }
  }
コード例 #19
0
ファイル: SubmitThread.java プロジェクト: xiongshaogang/smmp
  /** 将数据提交到运营商 */
  private void startSubmitData() {
    while (isContinue) {
      List<SmQueue> tempList = new LinkedList<SmQueue>();

      try {
        // 每晚23:58分暂停操作
        if (ConstantUtils.isPause_23_58()) {
          Thread.sleep(10 * 60 * 1000);
        }

        if (queue.size() >= (smgFlowLimit / 2) || isDrainTo()) {
          int num = queue.drainTo(tempList, (smgFlowLimit / 2));
          lastDrainToTime = System.currentTimeMillis();

          if (num > 0) {
            submitDataThreadPool.execute(new SubmitChildThread(tempList, channel));
          }
        } else {
          Thread.sleep(1000);
        }
      } catch (InterruptedException e1) {

      }
    }
  }
コード例 #20
0
  /**
   * {@inheritDoc} Sets up two caches: cache1 is local. cache2 is to be receive updates
   *
   * @throws Exception
   */
  @Override
  @Before
  public void setUp() throws Exception {

    // Required to get SoftReference tests to pass. The VM clean up SoftReferences rather than
    // allocating
    // memory to -Xmx!
    //        forceVMGrowth();
    //        System.gc();
    MulticastKeepaliveHeartbeatSender.setHeartBeatInterval(1000);

    manager1 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed1.xml");
    manager2 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed2.xml");
    manager3 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed3.xml");
    manager4 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed4.xml");
    manager5 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed5.xml");

    // manager6 = new CacheManager(AbstractCacheTest.TEST_CONFIG_DIR +
    // "distribution/ehcache-distributed-jndi6.xml");

    // allow cluster to be established
    Thread.sleep(1020);

    cache1 = manager1.getCache(cacheName);
    cache1.removeAll();

    cache2 = manager2.getCache(cacheName);
    cache2.removeAll();

    // enable distributed removeAlls to finish
    Thread.sleep(1500);
  }
コード例 #21
0
ファイル: MainTest.java プロジェクト: ValorVl/jDcHub
  @Test
  public void testRestart() throws Exception {
    // Start Server getInstance
    Main.main(new String[] {});

    log.info("\n\n\nWait for restart\n\n\n");
    Thread.sleep(5000);
    Main.restart();

    log.info("\n\n\nWait for two immediately restarts\n\n\n");
    Thread.sleep(5000);
    Main.restart();
    Main.restart();

    log.info("\n\n\nWait for concurent restarts\n\n\n");
    Thread.sleep(5000);
    for (int i = 0; i < 5; i++) {
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  Main.restart();
                }
              })
          .start();
    }
  }
コード例 #22
0
ファイル: Server.java プロジェクト: Kairus101/soccerRobots
  Server() throws IOException {
    if (useSerial) {
      ServerThread.initSerial();
      ServerThread.writeSerial(true);
      try {
        Thread.sleep(200);
      } catch (InterruptedException e1) {
      }
      ServerThread.writeSerial(true);
      try {
        Thread.sleep(200);
      } catch (InterruptedException e1) {
      }
      ServerThread.writeSerial(true);
    }

    int port = 10055;
    ServerSocket serverSocket = null;
    try {
      serverSocket = new ServerSocket(port);
      System.out.println("Soccer robots server active on port " + port + ".");
    } catch (IOException e) {
      System.err.println("Could not listen on port: " + port + ".");
      System.exit(-1);
    }
    while (true) {
      ServerThread tmp = new ServerThread(serverSocket.accept());
      threads.add(tmp);
    }
  }
コード例 #23
0
 @Override
 public void run() {
   while (running) {
     if (isOnline()) {
       Log.i(TAG, "DataUpdateService running...");
       // if the update has been done with successful, wait until the next day
       if (update(getApplicationContext())) {
         try {
           Thread.sleep(DELAY_OF_30_MIN);
         } catch (InterruptedException e) {
           e.printStackTrace();
         }
       }
     } else {
       // if it is not online, service wait for ten minutes to try again
       try {
         Thread.sleep(TEN_MINUTES);
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
   }
   Log.w(TAG, "DataUpdateService loop finished!");
   stopSelf();
 }
コード例 #24
0
  public static void main(String[] args) throws Exception {
    Admin admin = new AdminFactory().addGroup("kimchy").createAdmin();
    System.out.println("Start 1 GSM and 2 GSCs");
    admin.getGridServiceManagers().waitFor(1);
    System.out.println("Found at least 1 GSM");
    admin.getGridServiceContainers().waitFor(2);
    System.out.println("Found at least 2 GSC");
    ProcessingUnit procesingUnit =
        admin
            .getGridServiceManagers()
            .deploy(new ProcessingUnitDeployment("test").numberOfInstances(2));
    System.out.println("Deployed test processing unit, waiting...");
    procesingUnit.waitFor(2);
    System.out.println("Deployed space");

    System.out.println("Incrementing instance ...");
    procesingUnit.incrementInstance();
    System.out.println("Waiting for instance to increment...");
    procesingUnit.waitFor(3);
    System.out.println("Instance incremented");
    Thread.sleep(2000);
    System.out.println("Decrementing instance ...");
    procesingUnit.decrementInstance();
    Thread.sleep(10000);
    System.out.println("Waiting for instance to decrement...");
    while (!(procesingUnit.getInstances().length == 2)) {
      Thread.sleep(1000);
    }
    System.out.println("Instance decremented");
    System.out.println("Undeploying");
    procesingUnit.undeploy();
    System.out.println("Closing admin");
    admin.close();
  }
コード例 #25
0
  @Test(timeout = 2000)
  public void testCleanupQueueClosesFilesystem()
      throws IOException, InterruptedException, NoSuchFieldException, IllegalAccessException {
    Configuration conf = new Configuration();
    File file = new File("afile.txt");
    file.createNewFile();
    Path path = new Path(file.getAbsoluteFile().toURI());

    FileSystem.get(conf);
    Assert.assertEquals(1, getFileSystemCacheSize());

    // With UGI, should close FileSystem
    CleanupQueue cleanupQueue = new CleanupQueue();
    PathDeletionContext context =
        new PathDeletionContext(path, conf, UserGroupInformation.getLoginUser(), null, null);
    cleanupQueue.addToQueue(context);

    while (getFileSystemCacheSize() > 0) {
      Thread.sleep(100);
    }

    file.createNewFile();
    FileSystem.get(conf);
    Assert.assertEquals(1, getFileSystemCacheSize());

    // Without UGI, should not close FileSystem
    context = new PathDeletionContext(path, conf);
    cleanupQueue.addToQueue(context);

    while (file.exists()) {
      Thread.sleep(100);
    }
    Assert.assertEquals(1, getFileSystemCacheSize());
  }
  @Test
  public void testMaxCapacity() throws Exception {

    ListenableFuture<String> val =
        cache.apply(
            "Key1",
            () -> {
              try {
                Thread.sleep(1000);
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
              return "key1";
            },
            executorService);

    ListenableFuture<String> val2 =
        cache.apply(
            "key2",
            () -> {
              try {
                Thread.sleep(500);
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
              return "key2";
            },
            executorService);

    ListenableFuture<String> val3 =
        cache.apply(
            "key3",
            () -> {
              try {
                Thread.sleep(500);
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
              return "key3";
            },
            executorService);

    ListenableFuture<String> val4 =
        cache.apply(
            "key1",
            () -> {
              try {
                Thread.sleep(500);
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
              return "key_new";
            },
            executorService);

    assertEquals("Value should be key1", "key1", this.awaitForFutureOrElse(val, null));
    assertEquals("Value should be key2", "key2", this.awaitForFutureOrElse(val2, null));
    assertEquals("Value should be key3", "key3", this.awaitForFutureOrElse(val3, null));
    assertEquals("Value should be key1", "key_new", this.awaitForFutureOrElse(val4, null));
  }
コード例 #27
0
  private void waitUntilServerIsRunning(boolean reconnect)
      throws IOException, InterruptedException, TimeoutException {

    Thread.sleep(500); // this value is taken from implementation of CLI "reload"

    if (reconnect) {
      client.reconnect(timeoutInSeconds);
    }

    long endTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeoutInSeconds);
    while (System.currentTimeMillis() < endTime) {
      try {
        if (isServerRunning()) {
          break;
        }
      } catch (Throwable ignored) {
        // server is probably down, will retry
      }

      Thread.sleep(200); // this value is completely arbitrary
    }

    boolean running = false;
    try {
      running = isServerRunning();
    } catch (Throwable ignored) {
      // server probably down
    }
    if (!running) {
      throw new TimeoutException("Waiting for server timed out");
    }
  }
コード例 #28
0
  @Test(timeOut = 5 * 60 * 1000)
  public void testCreatePublicRootContainer() throws Exception {
    try {
      client.deleteRootContainer();
    } catch (ContainerNotFoundException e) {
      Thread.sleep(5000);
    } catch (AzureStorageResponseException htpe) {
      if (htpe.getResponse().getStatusCode() == 409) { // TODO look for specific message
        Thread.sleep(5000);
      } else {
        throw htpe;
      }
    }

    boolean created = false;
    while (!created) {
      try {
        created = client.createRootContainer();
      } catch (AzureStorageResponseException htpe) {
        if (htpe.getResponse().getStatusCode() == 409) { // TODO look for specific message
          Thread.sleep(5000);
          continue;
        } else {
          throw htpe;
        }
      }
    }
    ListBlobsResponse list = client.listBlobs();
    assertEquals(
        list.getUrl(),
        URI.create(String.format("https://%s.blob.core.windows.net/$root", identity)));
  }
コード例 #29
0
 /*
 This test will update the Synapse configuration
  */
 public void updateSynapseConfig() throws Exception {
   selenium.click("link=Synapse");
   Thread.sleep(2000);
   selenium.click("updateConfig");
   Thread.sleep(10000);
   selenium.click("//button[@type='button']");
 }
コード例 #30
0
ファイル: SourceWav.java プロジェクト: zleffke/FoxTelem
  @Override
  public void run() {
    running = true;
    done = false;
    Log.println("WAV Source START");
    if (audioStream == null)
      try {
        initWav();
      } catch (UnsupportedAudioFileException e1) {
        Log.errorDialog("ERROR", "Unsupported File Format\n" + e1.getMessage());
        e1.printStackTrace(Log.getWriter());
        running = false;
      } catch (IOException e1) {
        Log.errorDialog("ERROR", "There was a problem opening the wav file\n" + e1.getMessage());
        e1.printStackTrace(Log.getWriter());
        running = false;
      }

    while (running) {
      //			Log.println("wav running");
      if (audioStream != null) {
        int nBytesRead = 0;
        if (circularBuffer.getCapacity() > readBuffer.length) {
          try {
            nBytesRead = audioStream.read(readBuffer, 0, readBuffer.length);
            bytesRead = bytesRead + nBytesRead;
            framesProcessed = framesProcessed + nBytesRead / frameSize;
            // Check we have not stopped mid read
            if (audioStream == null) running = false;
            else if (!(audioStream.available() > 0)) running = false;
          } catch (IOException e) {
            Log.errorDialog("ERROR", "Failed to read from file " + fileName);
            e.printStackTrace(Log.getWriter());
          }
        } else {
          try {
            Thread.sleep(1);
          } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          // Log.println("No room in Buffer");
        }
        for (int i = 0; i < nBytesRead; i += 2) {
          // circularBuffer.add(readBuffer[i]);
          circularBuffer.add(readBuffer[i], readBuffer[i + 1]);
        }
      }
    }
    framesProcessed = totalFrames;
    cleanup(); // This might cause the decoder to miss the end of a file (testing inconclusive) but
               // it also ensure the file is close and stops an error if run again very quickly
    running = false;
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    Log.println("WAV Source EXIT");
  }