Пример #1
0
  private static void startWebSocketServer() {
    WebSocketCallback callback = new WebSocketCallback();

    String ip = "0.0.0.0";
    try {
      Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
      while (interfaces.hasMoreElements()) {
        NetworkInterface iface = interfaces.nextElement();
        // filters out 127.0.0.1 and inactive interfaces
        if (iface.isLoopback() || !iface.isUp()) continue;

        Enumeration<InetAddress> addresses = iface.getInetAddresses();
        while (addresses.hasMoreElements()) {
          InetAddress addr = addresses.nextElement();
          ip = addr.getHostAddress();
          Log.info(iface.getDisplayName() + " " + ip);
        }
      }
    } catch (SocketException e) {
      throw new RuntimeException(e);
    }

    Log.info("Starting server...");
    final String host = "0.0.0.0";
    Undertow server =
        Undertow.builder()
            .addHttpListener(8081, host)
            .setHandler(path().addPrefixPath("/ev3", websocket(callback)))
            .build();
    server.start();
    Log.info("Server started.");
    Log.info("Listening on " + ip + ":8081/ev3");
  }
Пример #2
0
  /** Create a new checkpoint */
  void doCheckpoint() throws IOException {

    LOG.info("Checkpoint starting");

    // Do the required initialization of the merge work area.
    startCheckpoint();

    // Tell the namenode to start logging transactions in a new edit file
    // Returns a token that would be used to upload the merged image.
    CheckpointSignature sig = (CheckpointSignature) namenode.rollEditLog();

    // error simulation code for junit test
    if (ErrorSimulator.getErrorSimulation(0)) {
      throw new IOException("Simulating error0 " + "after creating edits.new");
    }

    boolean loadImage = downloadCheckpointFiles(sig); // Fetch fsimage and edits
    doMerge(sig, loadImage); // Do the merge

    //
    // Upload the new image into the NameNode. Then tell the Namenode
    // to make this new uploaded image as the most current image.
    //
    putFSImage(sig);

    // error simulation code for junit test
    if (ErrorSimulator.getErrorSimulation(1)) {
      throw new IOException("Simulating error1 " + "after uploading new image to NameNode");
    }

    namenode.rollFsImage(new CheckpointSignature(checkpointImage));
    checkpointImage.endCheckpoint();

    LOG.info("Checkpoint done. New Image Size: " + checkpointImage.getFsImageName().length());
  }
Пример #3
0
  /**
   * Test that applying data as an operation to get back a copy of the data works correctly.
   *
   * <p>The other tests assume that this test always passes.
   *
   * @param numIterations
   */
  public void testDataOperationEquivalence(int numIterations) {
    log.info("TESTING testDataOperationEquivalence");
    Random r = new Random(0);

    for (int iteration = 0; iteration < numIterations; iteration++) {
      log.info("Iteration: " + iteration);

      D d1 = domain.initialState();

      try {
        for (int i = 0; i < INITIAL_MUTATION_COUNT; i++) {
          O op = generator.randomOperation(d1, r);
          domain.apply(op, d1);

          D d2 = domain.initialState();
          domain.apply(domain.asOperation(d1), d2);

          if (!domain.equivalent(d1, d2)) {
            log.inconsistent(
                "DATA-AS-OPERATION BUG",
                "Subiteration: " + i,
                "Op from data: " + domain.asOperation(d1),
                "Data: " + d1,
                "Result of op on fresh state: " + d2);
          }
        }
      } catch (OperationException e) {
        logException("DATA-AS-OPERATION BUG? Operation exception", e);
      } catch (RuntimeException e) {
        logException("DATA-AS-OPERATION BUG? Runtime exception", e);
      }
    }
  }
Пример #4
0
  private void handleRemoveFeedPost(Request request, HttpServletResponse httpServletResponse)
      throws Exception {
    LOG.info("removing feed");
    User user = userHelpers.getUser(request);

    try {
      if (user == null) {
        LOG.error("User not found");
        return;
      }

      String feedId = request.getParameter(PARAM_FEED_ID);

      LOG.info(String.format("Removing feed %s for user %s", feedId, user));

      // ttt1 add some validation; probably best try to actually get data, set the title, ...
      if (feedId == null || feedId.equals("")) {
        LOG.error("feed not specified");
        // ttt1 show some error
        return;
      }

      if (user.feedIds.remove(
          feedId)) { // ttt2 clean up the global feed table; that's probably better done if nobody
                     // accesses a feed for 3 months or so
        userDb.updateFeeds(user);
        LOG.info(String.format("Removed feed %s for user %s", feedId, user));
      } else {
        LOG.info(String.format("No feed found with ID %s for user %s", feedId, user));
      }
    } finally {
      httpServletResponse.sendRedirect(PATH_FEED_ADMIN);
    }
  }
Пример #5
0
  /**
   * Download <code>fsimage</code> and <code>edits</code> files from the name-node.
   *
   * @return true if a new image has been downloaded and needs to be loaded
   * @throws IOException
   */
  private boolean downloadCheckpointFiles(CheckpointSignature sig) throws IOException {

    checkpointImage.cTime = sig.cTime;
    checkpointImage.checkpointTime = sig.checkpointTime;

    boolean downloadImage = true;
    String fileid;
    File[] srcNames;
    if (sig.imageDigest.equals(checkpointImage.imageDigest)) {
      downloadImage = false;
      LOG.info("Image has not changed. Will not download image.");
    } else {
      // get fsimage
      srcNames = checkpointImage.getImageFiles();
      assert srcNames.length > 0 : "No checkpoint targets.";
      fileid = "getimage=1";
      TransferFsImage.getFileClient(fsName, fileid, srcNames, false);
      checkpointImage.imageDigest = sig.imageDigest;
      LOG.info(
          "Downloaded file " + srcNames[0].getName() + " size " + srcNames[0].length() + " bytes.");
    }
    // get edits file
    fileid = "getedit=1";
    srcNames = checkpointImage.getEditsFiles();
    assert srcNames.length > 0 : "No checkpoint targets.";
    TransferFsImage.getFileClient(fsName, fileid, srcNames, false);
    LOG.info(
        "Downloaded file " + srcNames[0].getName() + " size " + srcNames[0].length() + " bytes.");

    checkpointImage.checkpointUploadDone(null);

    return downloadImage;
  }
Пример #6
0
  public void init() throws ServletException {
    try {
      // Load configuration (from classpath or WEB-INF root path)
      String webInfPath = getServletContext().getRealPath("/") + "/WEB-INF";
      Config.load(webInfPath);
      Log.init();
      // Start
      Log.info(
          "init() Pushlet Webapp - version="
              + Version.SOFTWARE_VERSION
              + " built="
              + Version.BUILD_DATE);
      // Start session manager
      SessionManager.getInstance().start();
      // Start event Dispatcher
      Dispatcher.getInstance().start();

      if (Config.getBoolProperty(Config.SOURCES_ACTIVATE)) {
        EventSourceManager.start(webInfPath);
      } else {
        Log.info("Not starting local event sources");
      }
    } catch (Throwable t) {
      throw new ServletException("Failed to initialize Pushlet framework " + t, t);
    }
  }
Пример #7
0
  /**
   * SQL文の実行を行い、データの取得を行う。<br>
   * 取得したレコードの最初の行の最初の列データを返却する。
   *
   * @param sql 実行するSQL(select)
   * @return 取得データ
   */
  public String execQuerySingle(String sql) throws Exception {
    String result = null;
    try {
      Log.info("--- start execQuerySingle " + sql + " ---");
      if (con == null) {
        Log.warning("Connection is null -- run makeConnection");
        makeConnection();
      }
      Statement stmt = con.createStatement();
      Log.info("createStatement success");

      ResultSet rs = stmt.executeQuery(sql);

      if (rs.next()) {
        result = rs.getString(1);
      }
      Log.info("execQuerySingle " + sql + " success\nreturn data:" + result);

      rs.close();
      stmt.close();

    } catch (Exception e) {
      Log.warning("fail execQuerySingle : " + e.getLocalizedMessage() + "\nSQL : " + sql);
      throw e;
    }
    Log.info("--- end execQuerySingle " + sql + " ---");
    return result;
  }
Пример #8
0
  @Test(dataProvider = "composeAllPermutationsOfSamInputResource")
  public void queryInputResourcePermutation(final SamInputResource resource) throws IOException {
    final SamReader reader = SamReaderFactory.makeDefault().open(resource);
    LOG.info(String.format("Query from %s ...", resource));
    if (reader.hasIndex()) {
      final StopWatch stopWatch = new StopWatch();
      stopWatch.start();
      final SAMRecordIterator q1 = reader.query("chr1", 500000, 100000000, true);
      observedRecordOrdering1.add(Iterables.slurp(q1));
      q1.close();
      final SAMRecordIterator q20 = reader.query("chr20", 1, 1000000, true);
      observedRecordOrdering20.add(Iterables.slurp(q20));
      q20.close();
      final SAMRecordIterator q3 = reader.query("chr3", 1, 10000000, true);
      observedRecordOrdering3.add(Iterables.slurp(q3));
      q3.close();
      stopWatch.stop();
      LOG.info(String.format("Finished queries in %sms", stopWatch.getElapsedTime()));

      Assert.assertEquals(
          observedRecordOrdering1.size(), 1, "read different records for chromosome 1");
      Assert.assertEquals(
          observedRecordOrdering20.size(), 1, "read different records for chromosome 20");
      Assert.assertEquals(
          observedRecordOrdering3.size(), 1, "read different records for chromosome 3");
    } else if (resource.indexMaybe() != null) {
      LOG.warn("Resource has an index source, but is not indexed: " + resource);
    } else {
      LOG.info("Skipping query operation: no index.");
    }
    reader.close();
  }
Пример #9
0
  public void testTransformDiamondProperty(int numIterations) {
    log.info("TESTING testTransformDiamondProperty");
    Random r = new Random(0);

    for (int iteration = 0; iteration < numIterations; iteration++) {
      log.info("Iteration: " + iteration);

      D d1 = domain.initialState();

      try {
        for (int i = 0; i < INITIAL_MUTATION_COUNT; i++) {
          O op = generator.randomOperation(d1, r);
          domain.apply(op, d1);
        }

        D d2 = copy(d1);

        for (int i = 0; i < FEATURE_ITERATION_COUNT; i++) {
          D original = copy(d1);

          O op1 = generator.randomOperation(original, r);
          O op2 = generator.randomOperation(original, r);

          domain.apply(op1, d1);
          domain.apply(op2, d2);

          D client = copy(d1);
          D server = copy(d2);

          OperationPair<O> pair = domain.transform(op1, op2);

          domain.apply(pair.serverOp(), d1);
          domain.apply(pair.clientOp(), d2);

          if (!domain.equivalent(d1, d2)) {
            log.inconsistent(
                "TRANSFORM BUG",
                "Subiteration: " + i,
                "Client: " + op1,
                "Server: " + op2,
                "Client': " + pair.clientOp(),
                "Server': " + pair.serverOp(),
                "Initial state: " + original,
                "Client state 1:" + client,
                "Client state 2:" + d1,
                "Server state 1:" + server,
                "Server state 2:" + d2);
          }
        }

      } catch (OperationException e) {
        logException("TRANSFORM BUG? Operation exception", e);
      } catch (TransformException e) {
        logException("TRANSFORM BUG? Transform exception", e);
      } catch (RuntimeException e) {
        logException("TRANSFORM BUG? Runtime exception", e);
      }
    }
  }
Пример #10
0
  public void testLoggingWithNullParameters() {
    Log log = this.getLogObject();

    assertNotNull(log);

    log.debug(null);

    log.debug(null, null);

    log.debug(log.getClass().getName() + ": debug statement");

    log.debug(
        log.getClass().getName() + ": debug statement w/ null exception", new RuntimeException());

    log.error(null);

    log.error(null, null);

    log.error(log.getClass().getName() + ": error statement");

    log.error(
        log.getClass().getName() + ": error statement w/ null exception", new RuntimeException());

    log.fatal(null);

    log.fatal(null, null);

    log.fatal(log.getClass().getName() + ": fatal statement");

    log.fatal(
        log.getClass().getName() + ": fatal statement w/ null exception", new RuntimeException());

    log.info(null);

    log.info(null, null);

    log.info(log.getClass().getName() + ": info statement");

    log.info(
        log.getClass().getName() + ": info statement w/ null exception", new RuntimeException());

    log.trace(null);

    log.trace(null, null);

    log.trace(log.getClass().getName() + ": trace statement");

    log.trace(
        log.getClass().getName() + ": trace statement w/ null exception", new RuntimeException());

    log.warn(null);

    log.warn(null, null);

    log.warn(log.getClass().getName() + ": warn statement");

    log.warn(
        log.getClass().getName() + ": warn statement w/ null exception", new RuntimeException());
  }
 /**
  * Write the startup header for the logs to show what our inputs are.
  *
  * @param log The logger
  */
 private void logStartHeader(Log log) {
   log.info("Started Octopus Deploy");
   log.info("======================");
   log.info("Project: " + project);
   log.info("Version: " + releaseVersion);
   log.info("Environment: " + environment);
   log.info("======================");
 }
Пример #12
0
  /** Test that (a.b).c = a.(b.c) */
  public void testCompositionAssociativity(int numIterations) {
    log.info("TESTING testCompositionAssociativity");
    Random r = new Random(0);

    for (int iteration = 0; iteration < numIterations; iteration++) {
      log.info("Iteration: " + iteration);

      try {
        D d1 = domain.initialState();

        for (int i = 0; i < INITIAL_MUTATION_COUNT; i++) {
          O op = generator.randomOperation(d1, r);
          domain.apply(op, d1);
        }

        D d2 = copy(d1);
        D d3 = copy(d1);

        for (int i = 0; i < FEATURE_ITERATION_COUNT; i++) {
          D backup = copy(d1);

          O op1 = generator.randomOperation(d1, r);
          domain.apply(op1, d1);
          O op2 = generator.randomOperation(d1, r);
          domain.apply(op2, d1);
          O op3 = generator.randomOperation(d1, r);
          domain.apply(op3, d1);

          O op12 = domain.compose(op2, op1);
          O op23 = domain.compose(op3, op2);

          domain.apply(op1, d2);
          domain.apply(op23, d2);

          domain.apply(op12, d3);
          domain.apply(op3, d3);

          if (!domain.equivalent(d2, d3)) {
            log.inconsistent(
                "COMPOSE ASSOCIATIVITY BUG",
                "Subiteration: " + i,
                "Op1: " + op1,
                "Op2: " + op2,
                "Op3: " + op2,
                "Op2.Op1: " + op12,
                "Op3.Op2: " + op23,
                "Initial state: " + backup,
                "State after Op3.(Op2.Op1): " + d3,
                "State after (Op3.Op2).Op1: " + d2);
          }
        }
      } catch (OperationException e) {
        logException("COMPOSE BUG? Operation exception", e);
      } catch (RuntimeException e) {
        logException("COMPOSE BUG? Runtime exception", e);
      }
    }
  }
Пример #13
0
 /** トランザクションを明示的に開始する */
 public void begin() throws Exception {
   Log.info("--- start begin transactin ---");
   if (con != null) {
     Log.info("connection is alive! -- run commit transaction");
     commit();
   }
   makeConnection();
   Log.info("--- end begin transactin ---");
 }
Пример #14
0
 public void destroy() {
   Log.info("destroy(): Exit Pushlet webapp");
   if (Config.getBoolProperty(Config.SOURCES_ACTIVATE)) {
     // Stop local event sources
     EventSourceManager.stop();
   } else {
     Log.info("No local event sources to stop");
   }
   // Should abort all subscribers
   Dispatcher.getInstance().stop();
   // Should stop all sessions
   SessionManager.getInstance().stop();
 }
 /**
  * Load the GameCharacter from the database.
  *
  * @param name The (unique) name of the game character.
  * @return A GameCharacter object holding all information.
  * @exception UnknownUserException If no entry with the given name could be found in the database.
  */
 public static GameCharacter load(String name) throws UnknownUserException {
   // Load user state from database. This method throws a
   // UserNotFoundException if the user is not in the database.
   Log.info("CharacterState", "load", "Load data of character: " + name);
   try {
     GameCharacter character = JdbcUtil.loadCharacter(name);
     character.setStateful(true);
     Log.info("CharacterState", "load", "Character data loaded.");
     return character;
   } catch (NoRecordFoundException e) {
     throw new UnknownUserException("Character name: " + name);
   }
 }
Пример #16
0
 /** 現在のトランザクションをコミットする */
 public void commit() {
   Log.info("--- start commit transactin ---");
   if (con != null) {
     try {
       if (!con.isClosed()) {
         con.commit();
         con.close();
       }
     } catch (Exception e) {
       Log.warning("fail commit transaction : " + e.getLocalizedMessage());
     }
     con = null;
   }
   Log.info("--- end commit transactin ---");
 }
 public String checkForErrorAndLog(String orderId) {
   String eventLogTableContent = PageBase.OrderSummaryPage().eventLogTable.getText();
   String lines[] = eventLogTableContent.split("\n");
   Log.info("-------------------START ERROR INFO-----------------------------");
   Log.info("Error Info for Order Number:-" + orderId + "\n"); // ordreId
   Log.info("Order Status:-" + PageBase.OrderSummaryPage().statusValueLink.getText() + "\n");
   System.out.println(lines.length);
   for (int i = 0; i < lines.length; i++) {
     if (lines[i].contains("Error")) {
       Log.error(lines[i] + "\n");
     }
   }
   Log.info("---------------------END ERROR INFO---------------------------");
   return eventLogTableContent;
 }
Пример #18
0
  @Test
  @SuppressWarnings("deprecation")
  public void testOurLogLogging() {
    final Log logger = new Log();

    logger.trace("Foobar TRACE");
    AppenderForTests.hasNoLastEvent("at Trace level");
    assertFalse(logger.isTraceEnabled());

    logger.debug("Foobar DEBUG");
    AppenderForTests.hasNoLastEvent("at Debug level");
    assertFalse(logger.isDebugEnabled());

    logger.info("Foobar INFO");
    AppenderForTests.hasNoLastEvent("at Info level");
    assertFalse(logger.isInfoEnabled());

    logger.warn("Foobar WARN");
    AppenderForTests.hasLastEvent("at Warn level");
    assertTrue(logger.isWarnEnabled());

    logger.error("Foobar ERROR");
    AppenderForTests.hasLastEvent("at Error level");
    assertTrue(logger.isErrorEnabled());
  }
Пример #19
0
  public void stop() {
    synchronized (lock) {
      if (thread == null) return;
      Thread oldThread = thread;
      thread = null;

      Log.info("Stopping map renderer...");

      oldThread.interrupt();
      try {
        oldThread.join(1000);
      } catch (InterruptedException e) {
        Log.info("Waiting for map renderer to stop is interrupted");
      }
    }
  }
Пример #20
0
  private static void addFolder2(
      FileSystem fs, Path p, ArrayList<String> keys, ArrayList<String> failed) {
    try {
      if (fs == null) return;

      Futures futures = new Futures();
      for (FileStatus file : fs.listStatus(p)) {
        Path pfs = file.getPath();
        if (file.isDir()) {
          addFolder2(fs, pfs, keys, failed);
        } else {
          long size = file.getLen();
          Key res;
          if (pfs.getName().endsWith(Extensions.JSON)) {
            throw H2O.unimpl();
          } else if (pfs.getName().endsWith(Extensions.HEX)) { // Hex file?
            throw H2O.unimpl();
          } else {
            Key k = null;
            keys.add((k = HdfsFileVec.make(file, futures)).toString());
            Log.info("PersistHdfs: DKV.put(" + k + ")");
          }
        }
      }
    } catch (Exception e) {
      Log.err(e);
      failed.add(p.toString());
    }
  }
  @Override
  public double computeLikelihood(int classIndex, AttributeValue v) {
    if (v instanceof Null) return 1.0;
    if (!(v instanceof Histogram))
      throw new IllegalArgumentException(
          "Error: value " + v + " is not a Histogram for OntologyBernoulliEstimator.");

    Histogram val = null;
    if (v instanceof MappedHistogram) {
      List<URI> domain = mCut.get();
      MappedHistogram allV = (MappedHistogram) v;
      val = allV.induce(domain);
    } else {
      val = (Histogram) v;
    }

    if (val.size() != mCut.size())
      throw new IllegalArgumentException(
          "Error: size of "
              + v
              + " ("
              + val.size()
              + ") does not match the size of current cut ("
              + mCut.size()
              + ").");

    initLikelihood();

    Log.info(Arrays.toString(val.getIntArray(0)));
    return MathUtil.logBernoulliDist(mParameters[classIndex], val.getIntArray(0));
  }
Пример #22
0
 /* Uses resource to create default file, if file does not yet exist */
 public boolean createDefaultFileFromResource(String resourcename, File deffile) {
   if (deffile.canRead()) return true;
   Log.info(deffile.getPath() + " not found - creating default");
   InputStream in = getClass().getResourceAsStream(resourcename);
   if (in == null) {
     Log.severe("Unable to find default resource - " + resourcename);
     return false;
   } else {
     FileOutputStream fos = null;
     try {
       fos = new FileOutputStream(deffile);
       byte[] buf = new byte[512];
       int len;
       while ((len = in.read(buf)) > 0) {
         fos.write(buf, 0, len);
       }
     } catch (IOException iox) {
       Log.severe("ERROR creatomg default for " + deffile.getPath());
       return false;
     } finally {
       if (fos != null)
         try {
           fos.close();
         } catch (IOException iox) {
         }
       if (in != null)
         try {
           in.close();
         } catch (IOException iox) {
         }
     }
     return true;
   }
 }
Пример #23
0
    /**
     * May be called from within timeReached(), but schedule() is better there.
     *
     * @param timeoutMs
     * @param useEarliestTime if its already scheduled, use the earlier of the two timeouts, else
     *     use the later
     */
    public synchronized void reschedule(long timeoutMs, boolean useEarliestTime) {
      final long now = System.currentTimeMillis();
      long oldTimeout;
      boolean scheduled = _state == TimedEventState.SCHEDULED;
      if (scheduled) oldTimeout = _nextRun - now;
      else oldTimeout = timeoutMs;

      // don't bother rescheduling if within _fuzz ms
      if ((oldTimeout - _fuzz > timeoutMs && useEarliestTime)
          || (oldTimeout + _fuzz < timeoutMs && !useEarliestTime)
          || (!scheduled)) {
        if (scheduled && (now + timeoutMs) < _nextRun) {
          if (_log.shouldLog(Log.INFO))
            _log.info(
                "Re-scheduling: "
                    + this
                    + " timeout = "
                    + timeoutMs
                    + " old timeout was "
                    + oldTimeout
                    + " state: "
                    + _state);
          cancel();
        }
        schedule(timeoutMs);
      }
    }
Пример #24
0
  @Override
  public void onDisable() {
    if (componentManager != null) {
      int componentCount = componentManager.components.size();
      for (Component component : componentManager.components) {
        component.dispose();
      }
      componentManager.clear();
      Log.info("Unloaded " + componentCount + " components.");
    }

    if (mapManager != null) {
      mapManager.stopRendering();
      mapManager = null;
    }

    if (webServer != null) {
      webServer.shutdown();
      webServer = null;
    }
    /* Clean up all registered handlers */
    for (Event.Type t : event_handlers.keySet()) {
      List<Listener> ll = event_handlers.get(t);
      ll
          .clear(); /* Empty list - we use presence of list to remember that we've registered with Bukkit */
    }
    playerfacemgr = null;

    /* Don't clean up markerAPI - other plugins may still be accessing it */

    Debug.clearDebuggers();
  }
Пример #25
0
  public static Map<String, ZipEntry> getZipEntries(String zipFile) throws PatchCreationException {
    Map<String, ZipEntry> result = new HashMap<String, ZipEntry>();
    ZipFile zF = null;
    try {
      zF = new ZipFile(zipFile);

      for (Enumeration<? extends ZipEntry> zEntries = zF.entries(); zEntries.hasMoreElements(); ) {
        ZipEntry entry = (ZipEntry) zEntries.nextElement();
        if (!entry.isDirectory())
          if ((entry.getCrc() == -1L) || (entry.getCrc() == 0L)) {
            Log.info("warning: " + entry.getName() + " has wrong CRC or is a directory, ignoring");
          } else {
            result.put(entry.getName(), entry);
          }
      }
    } catch (Exception e) {
      throw new PatchCreationException("Problem getting zip entries", e);
    } finally {
      try {
        if (zF != null) zF.close();
      } catch (Exception e) {
      }
    }
    return result;
  }
Пример #26
0
  /** Initialize SecondaryNameNode. */
  private void initialize(Configuration conf) throws IOException {
    // initiate Java VM metrics
    JvmMetrics.init("SecondaryNameNode", conf.get("session.id"));

    // Create connection to the namenode.
    shouldRun = true;
    nameNodeAddr = NameNode.getAddress(conf);

    this.conf = conf;
    this.namenode =
        (NamenodeProtocol)
            RPC.waitForProxy(
                NamenodeProtocol.class, NamenodeProtocol.versionID, nameNodeAddr, conf);

    // initialize checkpoint directories
    fsName = getInfoServer();
    checkpointDirs = FSImage.getCheckpointDirs(conf, "/tmp/hadoop/dfs/namesecondary");
    checkpointEditsDirs = FSImage.getCheckpointEditsDirs(conf, "/tmp/hadoop/dfs/namesecondary");
    checkpointImage = new CheckpointStorage(conf);
    checkpointImage.recoverCreate(checkpointDirs, checkpointEditsDirs);

    // Initialize other scheduling parameters from the configuration
    checkpointPeriod = conf.getLong("fs.checkpoint.period", 3600);
    checkpointSize = conf.getLong("fs.checkpoint.size", 4194304);

    // initialize the webserver for uploading files.
    String infoAddr =
        NetUtils.getServerAddress(
            conf,
            "dfs.secondary.info.bindAddress",
            "dfs.secondary.info.port",
            "dfs.secondary.http.address");
    InetSocketAddress infoSocAddr = NetUtils.createSocketAddr(infoAddr);
    infoBindAddress = infoSocAddr.getHostName();
    int tmpInfoPort = infoSocAddr.getPort();
    infoServer = new HttpServer("secondary", infoBindAddress, tmpInfoPort, tmpInfoPort == 0, conf);
    infoServer.setAttribute("name.system.image", checkpointImage);
    this.infoServer.setAttribute("name.conf", conf);
    infoServer.addInternalServlet("getimage", "/getimage", GetImageServlet.class);
    infoServer.start();

    // The web-server port can be ephemeral... ensure we have the correct info
    infoPort = infoServer.getPort();
    conf.set("dfs.secondary.http.address", infoBindAddress + ":" + infoPort);
    LOG.info("Secondary Web-server up at: " + infoBindAddress + ":" + infoPort);
    LOG.warn(
        "Checkpoint Period   :"
            + checkpointPeriod
            + " secs "
            + "("
            + checkpointPeriod / 60
            + " min)");
    LOG.warn(
        "Log Size Trigger    :"
            + checkpointSize
            + " bytes "
            + "("
            + checkpointSize / 1024
            + " KB)");
  }
Пример #27
0
  /**
   * See if the provided object reference has any children that may help satisfy the recognition
   * string. This is essentially how this Iterator is "reentrant". Objects matching pieces of our
   * ObjectVector are added to the statically shared matches collection until the final Object
   * satisfying the entire ObjectVector is found.
   *
   * <p>Throughout the process we must maintain an accurate count of each class and its associated
   * object type in each child branch. In this way, we keep track of when we have found the nth
   * Index of a class or an associated object type in the branch. Thus, for each object encountered,
   * we must increment both the class count, and t he object type count for that class in this
   * branch.
   *
   * <p>Note, as we go down an object hierarchy branch, the counts increment. However, when we reset
   * back up to a higher level in the object hierarchy to go down a new branch, the counts must be
   * reset to those counts that were valid on entry at that level.
   *
   * <p>This function is only called internally.
   *
   * <p>
   *
   * @param achild the Object to process for children.
   *     <p>
   * @param agovVector the currently active GuiObjectVector.
   *     <p>
   * @param agovLevel the hierarchy level in the GuiObjectVector we are trying to satisfy.
   *     <p>
   * @param aobjLevel the level in the actual object hierarchy we are searching.
   *     <p>
   * @param classindices the storage of current class counts.
   *     <p>
   * @param typeindices the storage of current object type counts.
   * @author Carl Nagle, SEP 02, 2004 modified processChildren to skip checking children of
   *     Comboboxes
   */
  protected void processChildren(
      Object achild,
      GuiObjectVector agovVector,
      int agovLevel,
      int aobjLevel,
      Hashtable classindices,
      Hashtable typeindices,
      String typeclass) {

    GuiObjectRecognition agor = agovVector.getParentGuiObjectRecognition();
    String classname = agor.getObjectClassName(achild);

    // CANAGL -- do not seek children in comboboxes.  messes pushbutton counts!
    try {
      if (GuiClassData.classtypeContainsClassType(typeclass, "ComboBox")) {
        Log.debug("GCI: No children sought for ComboBoxes");
        return;
      }
      // if Domain = HTML and typeclass = PushButton
      if ((classname.toLowerCase().startsWith("html"))
          && (GuiClassData.classtypeContainsClassType(typeclass, "PushButton"))) {
        Log.debug("GCI: No children sought for HTML PushButtons");
        return;
      }
    } catch (Exception x) {;
    }

    // may be cached keys to proxies during EXTERNAL_PROCESSING
    Object[] childsChildren = agovVector.getChildObjects(achild);

    if ((childsChildren instanceof Object) && (childsChildren.length > 0)) {

      Log.info("GCI: " + childsChildren.length + " children in " + classname);
      Log.info("..........Child:" + classname + ", typeclass: " + typeclass);
      GuiChildIterator it = agovVector.createGuiChildIterator(gather);

      boolean isTab =
          (GuiClassData.classtypeContainsClassType(typeclass, "TabControl"))
              || (GuiClassData.classtypeContainsClassType(classname, "Html.HtmlBrowser"));

      // childsChildren may be cached keys during EXTERNAL_PROCESSING
      it.processNextLevel(
          childsChildren, agovVector, agovLevel, aobjLevel, classindices, typeindices, isTab);
    } else {
      Log.debug("GCI: No children found for " + classname);
    }
  }
Пример #28
0
  /**
   * Get a proxy connection to a remote server
   *
   * @param protocol protocol class
   * @param clientVersion client version
   * @param addr remote address
   * @param conf configuration to use
   * @param rpcTimeout timeout for each RPC
   * @param timeout time in milliseconds before giving up
   * @return the proxy
   * @throws IOException if the far end through a RemoteException
   */
  static <T extends VersionedProtocol> ProtocolProxy<T> waitForProtocolProxy(
      Class<T> protocol,
      long clientVersion,
      InetSocketAddress addr,
      Configuration conf,
      long timeout,
      int rpcTimeout)
      throws IOException {
    long startTime = System.currentTimeMillis();
    UserGroupInformation ugi = null;
    try {
      ugi = UserGroupInformation.login(conf);
    } catch (LoginException le) {
      throw new RuntimeException("Couldn't login!");
    }
    IOException ioe;
    while (true) {
      try {
        return getProtocolProxy(
            protocol,
            clientVersion,
            addr,
            ugi,
            conf,
            NetUtils.getDefaultSocketFactory(conf),
            rpcTimeout);
      } catch (ConnectException se) { // namenode has not been started
        LOG.info("Server at " + addr + " not available yet, Zzzzz...");
        ioe = se;
      } catch (SocketTimeoutException te) { // namenode is busy
        LOG.info("Problem connecting to server: " + addr);
        ioe = te;
      }
      // check if timed out
      if (System.currentTimeMillis() - timeout >= startTime) {
        throw ioe;
      }

      // wait for retry
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ie) {
        // IGNORE
      }
    }
  }
Пример #29
0
  private void reloadPlugin(Player sender) {
    Log.info("'" + sender.getName() + "' requested reload of ObsidianDestroyer");
    sender.sendMessage(ChatColor.GREEN + "Reloading ObsidianDestroyer!");

    if (plugin.reload()) {
      sender.sendMessage(ChatColor.GREEN + "Success!");
    }
  }
  /**
   * Returns control when task is complete.
   *
   * @param json
   * @param logger
   */
  private String waitForDeploymentCompletion(JSON json, OctopusApi api, Log logger) {
    final long WAIT_TIME = 5000;
    final double WAIT_RANDOM_SCALER = 100.0;
    JSONObject jsonObj = (JSONObject) json;
    String id = jsonObj.getString("TaskId");
    Task task = null;
    String lastState = "Unknown";
    try {
      task = api.getTask(id);
    } catch (IOException ex) {
      logger.error("Error getting task: " + ex.getMessage());
      return null;
    }

    logger.info("Task info:");
    logger.info("\tId: " + task.getId());
    logger.info("\tName: " + task.getName());
    logger.info("\tDesc: " + task.getDescription());
    logger.info("\tState: " + task.getState());
    logger.info("\n\nStarting wait...");
    boolean completed = task.getIsCompleted();
    while (!completed) {
      try {
        task = api.getTask(id);
      } catch (IOException ex) {
        logger.error("Error getting task: " + ex.getMessage());
        return null;
      }

      completed = task.getIsCompleted();
      lastState = task.getState();
      logger.info("Task state: " + lastState);
      if (completed) {
        break;
      }
      try {
        Thread.sleep(WAIT_TIME + (long) (Math.random() * WAIT_RANDOM_SCALER));
      } catch (InterruptedException ex) {
        logger.info("Wait interrupted!");
        logger.info(ex.getMessage());
        completed = true; // bail out of wait loop
      }
    }
    logger.info("Wait complete!");
    return lastState;
  }