コード例 #1
0
    @Override
    public void run() {
      Thread current = Thread.currentThread();
      String name = current.getName();
      current.setName(name + "-acceptor-" + _acceptor + "-" + AbstractConnector.this);

      synchronized (AbstractConnector.this) {
        _acceptors[_acceptor] = current;
      }

      try {
        while (isAccepting()) {
          try {
            accept(_acceptor);
          } catch (Throwable e) {
            if (isAccepting()) LOG.warn(e);
            else LOG.debug(e);
          }
        }
      } finally {
        current.setName(name);

        synchronized (AbstractConnector.this) {
          _acceptors[_acceptor] = null;
        }
        _stopping.countDown();
      }
    }
コード例 #2
0
ファイル: ModelChecker.java プロジェクト: sprig/MPS
 @Override
 public Project getProject() {
   if (LOG.isEnabledFor(Priority.WARN)) {
     LOG.warn("Using getProject() from IOperationContext strictly prohibited");
   }
   return super.getProject();
 }
コード例 #3
0
ファイル: GIndentBlock_TextGen.java プロジェクト: sprig/MPS
 public void doGenerateText(SNode node) {
   if (getBuffer().hasPositionsSupport()) {
     TraceInfoGenerationUtil.createPositionInfo(this, node);
   }
   this.increaseDepth();
   TextGenManager.instance()
       .appendNodeText(
           this.getContext(),
           this.getBuffer(),
           SLinkOperations.getTarget(node, "itemList", true),
           this.getSNode());
   this.decreaseDepth();
   if (getBuffer().hasPositionsSupport()) {
     {
       String traceableProperty = "";
       try {
         traceableProperty =
             BehaviorReflection.invokeVirtual(
                 String.class,
                 SNodeOperations.cast(
                     node, "jetbrains.mps.lang.traceable.structure.TraceableConcept"),
                 "virtual_getTraceableProperty_5067982036267369901",
                 new Object[] {});
       } catch (Throwable t) {
         if (LOG.isEnabledFor(Priority.ERROR)) {
           LOG.error("Can't calculate traceable prorerty for a node " + node + ".", t);
         }
       }
       TraceInfoGenerationUtil.fillPositionInfo(this, node, traceableProperty);
     }
   }
 }
コード例 #4
0
 public boolean check() {
   final Properties oldProps = new Properties();
   if (BindingFileSearch.CACHE_LIST.exists()) {
     try {
       Reader propIn = Files.newReader(BindingFileSearch.CACHE_LIST, Charset.defaultCharset());
       oldProps.load(propIn);
     } catch (Exception ex) {
       LOG.debug(ex, ex);
     }
   }
   Map<String, String> oldBindings = Maps.fromProperties(oldProps);
   Map<String, String> newBindings = Maps.fromProperties(BindingFileSearch.CURRENT_PROPS);
   if (oldBindings.equals(newBindings)) {
     LOG.info("Found up-to-date binding class cache: skipping message binding.");
     return true;
   } else {
     MapDifference<String, String> diffBindings = Maps.difference(oldBindings, newBindings);
     LOG.info("Binding class cache expired (old,new): \n" + diffBindings.entriesDiffering());
     try {
       Files.deleteRecursively(SubDirectory.CLASSCACHE.getFile());
     } catch (IOException ex) {
       LOG.error(ex, ex);
     }
     SubDirectory.CLASSCACHE.getFile().mkdir();
     return false;
   }
 }
コード例 #5
0
 public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
   try {
     MPSPropertiesConfigurable configurable =
         new ModulePropertiesConfigurable(
             ((SModule) MapSequence.fromMap(_params).get("module")),
             ((IOperationContext) MapSequence.fromMap(_params).get("context")).getProject());
     final SingleConfigurableEditor configurableEditor =
         new SingleConfigurableEditor(
             ProjectHelper.toIdeaProject(
                 ((IOperationContext) MapSequence.fromMap(_params).get("context")).getProject()),
             configurable,
             "#MPSPropertiesConfigurable");
     configurable.setParentForCallBack(configurableEditor);
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             configurableEditor.show();
           }
         });
   } catch (Throwable t) {
     if (LOG.isEnabledFor(Level.ERROR)) {
       LOG.error("User's action execute method failed. Action:" + "ModuleProperties", t);
     }
   }
 }
コード例 #6
0
    public void run() {
      LOG.info("ClientSessionTimeoutCheckThread started");
      while (!queryMasterStop.get()) {
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          break;
        }
        List<QueryMasterTask> tempTasks = new ArrayList<QueryMasterTask>();
        synchronized (queryMasterTasks) {
          tempTasks.addAll(queryMasterTasks.values());
        }

        for (QueryMasterTask eachTask : tempTasks) {
          if (!eachTask.isStopped()) {
            try {
              long lastHeartbeat = eachTask.getLastClientHeartbeat();
              long time = System.currentTimeMillis() - lastHeartbeat;
              if (lastHeartbeat > 0 && time > querySessionTimeout * 1000) {
                LOG.warn(
                    "Query "
                        + eachTask.getQueryId()
                        + " stopped cause query sesstion timeout: "
                        + time
                        + " ms");
                eachTask.expiredSessionTimeout();
              }
            } catch (Exception e) {
              LOG.error(eachTask.getQueryId() + ":" + e.getMessage(), e);
            }
          }
        }
      }
    }
コード例 #7
0
 @Override
 public void suspendChildren() throws CommandException {
   for (BundleActionBean action : this.bundleActions) {
     if (action.getStatus() == Job.Status.RUNNING
         || action.getStatus() == Job.Status.RUNNINGWITHERROR
         || action.getStatus() == Job.Status.PREP
         || action.getStatus() == Job.Status.PAUSED
         || action.getStatus() == Job.Status.PAUSEDWITHERROR) {
       // queue a CoordSuspendXCommand
       if (action.getCoordId() != null) {
         queue(new CoordSuspendXCommand(action.getCoordId()));
         updateBundleAction(action);
         LOG.debug(
             "Suspend bundle action = [{0}], new status = [{1}], pending = [{2}] and queue CoordSuspendXCommand for [{3}]",
             action.getBundleActionId(),
             action.getStatus(),
             action.getPending(),
             action.getCoordId());
       } else {
         updateBundleAction(action);
         LOG.debug(
             "Suspend bundle action = [{0}], new status = [{1}], pending = [{2}] and coord id is null",
             action.getBundleActionId(), action.getStatus(), action.getPending());
       }
     }
   }
   LOG.debug("Suspended bundle actions for the bundle=[{0}]", jobId);
 }
コード例 #8
0
  /**
   * Test of getTVChanges method, of class TmdbTV.
   *
   * @throws com.omertron.themoviedbapi.MovieDbException
   */
  @Test
  public void testGetTVChanges() throws MovieDbException {
    LOG.info("getTVChanges");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String startDate = sdf.format(DateUtils.addDays(new Date(), -14));
    String endDate = "";
    int maxCheck = 5;

    TmdbChanges chgs = new TmdbChanges(getApiKey(), getHttpTools());
    ResultList<ChangeListItem> changeList = chgs.getChangeList(MethodBase.TV, null, null, null);
    LOG.info(
        "Found {} changes to check, will check maximum of {}",
        changeList.getResults().size(),
        maxCheck);

    int count = 1;
    ResultList<ChangeKeyItem> result;
    for (ChangeListItem item : changeList.getResults()) {
      result = instance.getTVChanges(item.getId(), startDate, endDate);
      for (ChangeKeyItem ci : result.getResults()) {
        assertNotNull("Null changes", ci);
      }

      if (count++ > maxCheck) {
        break;
      }
    }
  }
コード例 #9
0
    @Override
    public void onClose(CachedOutputStream cos) {
      long l = LOG.logStart();
      byte[] buf = new byte[1024];
      int len;
      InputStream is;
      try {
        is = cos.getInputStream();
        while ((len = is.read(buf)) > 0) {
          logOutputStream.write(buf, 0, len);
        }
      } catch (IOException ex) {
        LOG.logError(l, ex);
      }
      LoggingMessage buffer = setupBuffer(message, fout);
      LOG.log(buffer.toString());

      try {
        // empty out the cache
        cos.lockOutputStream();
        cos.resetOut(null, false);
      } catch (Exception ex) {
        LOG.logWarn(l, "Error clearing cache: " + ex.getMessage(), null);
      }
      message.setContent(OutputStream.class, origStream);
    }
コード例 #10
0
  @Test
  public void info() throws DockerException {
    // Make sure that there is at least one container for the assertion
    // TODO extract this into a shared method
    if (dockerClient.listContainersCmd().withShowAll(true).exec().size() == 0) {
      CreateContainerResponse container =
          dockerClient
              .createContainerCmd("busybox")
              .withName("docker-java-itest-info")
              .withCmd("touch", "/test")
              .exec();

      LOG.info("Created container: {}", container);
      assertThat(container.getId(), not(isEmptyOrNullString()));

      dockerClient.startContainerCmd(container.getId()).exec();
    }

    Info dockerInfo = dockerClient.infoCmd().exec();
    LOG.info(dockerInfo.toString());

    assertTrue(dockerInfo.toString().contains("containers"));
    assertTrue(dockerInfo.toString().contains("images"));
    assertTrue(dockerInfo.toString().contains("debug"));

    assertTrue(dockerInfo.getContainers() > 0);
    assertTrue(dockerInfo.getImages() > 0);
    assertTrue(dockerInfo.getNFd() > 0);
    assertTrue(dockerInfo.getNGoroutines() > 0);
    assertTrue(dockerInfo.getNCPU() > 0);
  }
コード例 #11
0
  /**
   * This method to check whether 'lookupreturn' is specified if lookupclass is selected.
   *
   * @param maintenanceDocument
   * @return
   */
  private boolean checkLookupReturn(MaintenanceDocument maintenanceDocument) {
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "New maintainable is: " + maintenanceDocument.getNewMaintainableObject().getClass());
    }
    ProposalColumnsToAlter newEditableProposalField =
        (ProposalColumnsToAlter) maintenanceDocument.getNewMaintainableObject().getDataObject();

    if (StringUtils.isNotBlank(newEditableProposalField.getLookupClass())) {
      GlobalVariables.getUserSession()
          .addObject(
              Constants.LOOKUP_CLASS_NAME, (Object) newEditableProposalField.getLookupClass());
    }
    if (StringUtils.isNotBlank(newEditableProposalField.getLookupClass())
        && StringUtils.isBlank(newEditableProposalField.getLookupReturn())) {
      GlobalVariables.getMessageMap()
          .putError(
              Constants.PROPOSAL_EDITABLECOLUMN_LOOKUPRETURN,
              RiceKeyConstants.ERROR_REQUIRED,
              new String[] {"Lookup Return"});
      return false;
    }

    return true;
  }
コード例 #12
0
    public final void run() {
      byte[] buf = new byte[PayloadUtil.MTU];
      try {
        while (!stopped) {
          DatagramPacket packet = new DatagramPacket(buf, buf.length);
          try {
            socket.receive(packet);
            byte[] payload = packet.getData();
            processPayload(payload);

          } catch (IOException e) {
            if (!stopped) {
              LOG.log(
                  Level.SEVERE,
                  "Error receiving heartbeat. "
                      + e.getMessage()
                      + ". Initial cause was "
                      + e.getMessage(),
                  e);
            }
          }
        }
      } catch (Throwable t) {
        LOG.log(
            Level.SEVERE,
            "Multicast receiver thread caught throwable. Cause was "
                + t.getMessage()
                + ". Continuing...");
      }
    }
コード例 #13
0
  /* (non-Javadoc)
   * @see org.apache.oozie.command.XCommand#eagerVerifyPrecondition()
   */
  @Override
  protected void eagerVerifyPrecondition() throws CommandException, PreconditionException {
    validateChangeValue(changeValue);

    if (bundleJob == null) {
      LOG.info("BundleChangeCommand not succeeded - " + "job " + jobId + " does not exist");
      throw new PreconditionException(ErrorCode.E1314, jobId);
    }
    if (isChangePauseTime) {
      if (bundleJob.getStatus() == Job.Status.SUCCEEDED
          || bundleJob.getStatus() == Job.Status.FAILED
          || bundleJob.getStatus() == Job.Status.KILLED
          || bundleJob.getStatus() == Job.Status.DONEWITHERROR
          || bundleJob == null) {
        LOG.info(
            "BundleChangeCommand not succeeded for changing pausetime- "
                + "job "
                + jobId
                + " finished, status is "
                + bundleJob.getStatusStr());
        throw new PreconditionException(ErrorCode.E1312, jobId, bundleJob.getStatus().toString());
      }
    } else if (isChangeEndTime) {
      if (bundleJob.getStatus() == Job.Status.KILLED || bundleJob == null) {
        LOG.info(
            "BundleChangeCommand not succeeded for changing endtime- "
                + "job "
                + jobId
                + " finished, status is "
                + bundleJob.getStatusStr());
        throw new PreconditionException(ErrorCode.E1312, jobId, bundleJob.getStatus().toString());
      }
    }
  }
コード例 #14
0
 @Override
 public void timeseriesAggregate(
     RpcController controller,
     AggregateProtos.TimeSeriesAggregateRequest request,
     RpcCallback<AggregateProtos.AggregateResult> done) {
   AggregateResult result = null;
   try {
     result =
         this.aggregate(
             ProtoBufConverter.fromPBEntityDefinition(request.getEntityDefinition()),
             ProtoBufConverter.fromPBScan(request.getScan()),
             ProtoBufConverter.fromPBStringList(request.getGroupbyFieldsList()),
             ProtoBufConverter.fromPBByteArrayList(request.getAggregateFuncTypesList()),
             ProtoBufConverter.fromPBStringList(request.getAggregatedFieldsList()),
             request.getStartTime(),
             request.getEndTime(),
             request.getIntervalMin());
   } catch (IOException e) {
     LOG.error("Failed to convert result to PB-based message", e);
     ResponseConverter.setControllerException(controller, e);
   }
   try {
     done.run(ProtoBufConverter.toPBAggregateResult(result));
   } catch (IOException e) {
     LOG.error("Failed to convert result to PB-based message", e);
     ResponseConverter.setControllerException(controller, e);
   }
 }
コード例 #15
0
    public void handle(Event event) {
      if (blockNewEvents) {
        return;
      }
      drained = false;

      /* all this method does is enqueue all the events onto the queue */
      int qSize = eventQueue.size();
      if (qSize != 0 && qSize % 1000 == 0) {
        LOG.info("Size of event-queue is " + qSize);
      }
      int remCapacity = eventQueue.remainingCapacity();
      if (remCapacity < 1000) {
        LOG.warn("Very low remaining capacity in the event-queue: " + remCapacity);
      }
      try {
        eventQueue.put(event);
      } catch (InterruptedException e) {
        if (!stopped) {
          LOG.warn("AsyncDispatcher thread interrupted", e);
        }
        // Need to reset drained flag to true if event queue is empty,
        // otherwise dispatcher will hang on stop.
        drained = eventQueue.isEmpty();
        throw new YarnRuntimeException(e);
      }
    };
コード例 #16
0
ファイル: CoordRerunXCommand.java プロジェクト: InMobi/oozie
 /**
  * Refresh an action's input and ouput events.
  *
  * @param coordJob coordinator job bean
  * @param coordAction coordinator action bean
  * @throws Exception thrown if failed to materialize coordinator action
  */
 private void refreshAction(CoordinatorJobBean coordJob, CoordinatorActionBean coordAction)
     throws Exception {
   Configuration jobConf = null;
   try {
     jobConf = new XConfiguration(new StringReader(coordJob.getConf()));
   } catch (IOException ioe) {
     LOG.warn("Configuration parse error. read from DB :" + coordJob.getConf(), ioe);
     throw new CommandException(ErrorCode.E1005, ioe.getMessage(), ioe);
   }
   String jobXml = coordJob.getJobXml();
   Element eJob = XmlUtils.parseXml(jobXml);
   Date actualTime = new Date();
   String actionXml =
       CoordCommandUtils.materializeOneInstance(
           jobId,
           dryrun,
           (Element) eJob.clone(),
           coordAction.getNominalTime(),
           actualTime,
           coordAction.getActionNumber(),
           jobConf,
           coordAction);
   LOG.debug(
       "Refresh Action actionId="
           + coordAction.getId()
           + ", actionXml="
           + XmlUtils.prettyPrint(actionXml).toString());
   coordAction.setActionXml(actionXml);
 }
コード例 #17
0
    public SessionTerminal(CommandProcessor commandProcessor, ThreadIO threadIO)
        throws IOException {
      try {
        this.terminal = new Terminal(TERM_WIDTH, TERM_HEIGHT);
        terminal.write("\u001b\u005B20\u0068"); // set newline mode on

        in = new PipedOutputStream();
        out = new PipedInputStream();
        PrintStream pipedOut = new PrintStream(new PipedOutputStream(out), true);

        console =
            createConsole(
                commandProcessor, new PipedInputStream(in), pipedOut, threadIO, getBundleContext());
        CommandSession session = factory.getSession(console);
        session.put("APPLICATION", System.getProperty("karaf.name", "root"));
        // TODO: user should likely be the logged in user, eg we can grab that from the user servlet
        session.put("USER", "karaf");
        session.put("COLUMNS", Integer.toString(TERM_WIDTH));
        session.put("LINES", Integer.toString(/*TERM_HEIGHT*/ 39));
      } catch (IOException e) {
        LOG.info("Exception attaching to console", e);
        throw e;
      } catch (Exception e) {
        LOG.info("Exception attaching to console", e);
        throw (IOException) new IOException().initCause(e);
      }
      new Thread((Runnable) console).start();
      new Thread(this).start();
    }
コード例 #18
0
ファイル: CoordRerunXCommand.java プロジェクト: InMobi/oozie
  /**
   * Update an action into database table
   *
   * @param coordJob coordinator job bean
   * @param coordAction coordinator action bean
   * @throws Exception thrown failed to update coordinator action bean or unable to write sla
   *     registration event
   */
  private void updateAction(CoordinatorJobBean coordJob, CoordinatorActionBean coordAction)
      throws Exception {
    LOG.debug("updateAction for actionId=" + coordAction.getId());
    if (coordAction.getStatus() == CoordinatorAction.Status.TIMEDOUT) {
      LOG.debug("Updating created time for TIMEDOUT action id =" + coordAction.getId());
      coordAction.setCreatedTime(new Date());
    }
    coordAction.setStatus(CoordinatorAction.Status.WAITING);
    if (!failed) {
      coordAction.setExternalId(null);
    }
    coordAction.setExternalStatus(null);
    coordAction.setRerunTime(new Date());
    coordAction.setLastModifiedTime(new Date());
    coordAction.setErrorCode("");
    coordAction.setErrorMessage("");

    // Pushing the configuration which passed through rerun.
    if (actionRunConf != null && actionRunConf.size() > 0) {
      Configuration createdConf = null;
      if (coordAction.getCreatedConf() != null) {
        createdConf = new XConfiguration(new StringReader(coordAction.getCreatedConf()));
      } else {
        createdConf = new Configuration();
      }
      createdConf.set(RERUN_CONF, XmlUtils.prettyPrint(actionRunConf).toString());
      coordAction.setCreatedConf(XmlUtils.prettyPrint(createdConf).toString());
    }
    updateList.add(
        new UpdateEntry<CoordActionQuery>(CoordActionQuery.UPDATE_COORD_ACTION_RERUN, coordAction));
    writeActionRegistration(
        coordAction.getActionXml(), coordAction, coordJob.getUser(), coordJob.getGroup());
  }
コード例 #19
0
 public synchronized void flush() throws IOException {
   LOG.info("Starting flush of map output");
   synchronized (spillLock) {
     while (kvstart != kvend) {
       try {
         reporter.progress();
         spillLock.wait();
       } catch (InterruptedException e) {
         throw (IOException)
             new IOException("Buffer interrupted while waiting for the writer").initCause(e);
       }
     }
   }
   if (sortSpillException != null) {
     throw (IOException) new IOException("Spill failed").initCause(sortSpillException);
   }
   if (kvend != kvindex) {
     LOG.info("bufstart = " + bufstart + "; bufend = " + bufmark + "; bufvoid = " + bufvoid);
     LOG.info(
         "kvstart = " + kvstart + "; kvend = " + kvindex + "; length = " + kvoffsets.length);
     kvend = kvindex;
     bufend = bufmark;
     sortAndSpill();
   }
   // release sort buffer before the merge
   kvbuffer = null;
   mergeParts();
 }
コード例 #20
0
 @Override
 public void resultChanged(LookupEvent ev) {
   TopComponent tc = ref.get();
   if (tc == null) {
     r.removeLookupListener(this);
     synchronized (lookupListeners) {
       lookupListeners.remove(this);
     }
     return;
   }
   if (LOG.isLoggable(Level.FINER)) {
     LOG.log(Level.FINER, "  looking result changed for {0} ", new Object[] {ref.get()});
   }
   DataObject tcDataObject = tc.getLookup().lookup(DataObject.class);
   if (tcDataObject != null) {
     try {
       if (hasOpenedEditorPanes(tcDataObject)) {
         addOpenedFiles(getFiles(tcDataObject));
       }
     } catch (InterruptedException ex) {
       LOG.log(Level.WARNING, null, ex);
     } catch (InvocationTargetException ex) {
       LOG.log(Level.WARNING, null, ex);
     }
     r.removeLookupListener(this);
     synchronized (lookupListeners) {
       lookupListeners.remove(this);
     }
   }
 }
コード例 #21
0
ファイル: Database.java プロジェクト: rspengle/intermine
 public void run() {
   try {
     while (true) {
       SqlJob job = null;
       Connection c = null;
       try {
         job = queue.take();
         c = getConnection();
         c.setAutoCommit(true);
         Statement s = c.createStatement();
         s.execute(job.getSql());
       } catch (SQLException e) {
         if (job != null) {
           LOG.error("Exception while executing " + job.getSql(), e);
         }
         reportException(e);
       } finally {
         if (job != null) {
           jobIsDone(job);
         }
         if (c != null) {
           c.close();
         }
       }
     }
   } catch (Throwable t) {
     LOG.error("Database background thread " + threadNo + " exited unexpectedly", t);
   } finally {
     workers.remove(this);
   }
 }
コード例 #22
0
  @Override
  public boolean rename(Path src, Path dst) throws IOException {
    // Attempt rename using Java API.
    File srcFile = pathToFile(src);
    File dstFile = pathToFile(dst);
    if (srcFile.renameTo(dstFile)) {
      return true;
    }

    // Enforce POSIX rename behavior that a source directory replaces an existing
    // destination if the destination is an empty directory.  On most platforms,
    // this is already handled by the Java API call above.  Some platforms
    // (notably Windows) do not provide this behavior, so the Java API call above
    // fails.  Delete destination and attempt rename again.
    if (this.exists(dst)) {
      FileStatus sdst = this.getFileStatus(dst);
      if (sdst.isDirectory() && dstFile.list().length == 0) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Deleting empty destination and renaming " + src + " to " + dst);
        }
        if (this.delete(dst, false) && srcFile.renameTo(dstFile)) {
          return true;
        }
      }
    }

    // The fallback behavior accomplishes the rename by a full copy.
    if (LOG.isDebugEnabled()) {
      LOG.debug("Falling through to a copy of " + src + " to " + dst);
    }
    return FileUtil.copy(this, src, this, dst, true, getConf());
  }
コード例 #23
0
 public static void processFiles() {
   final File libDir = new File(BaseDirectory.LIB.toString());
   for (final File f : libDir.listFiles()) {
     if (f.getName().startsWith("eucalyptus")
         && f.getName().endsWith(".jar")
         && !f.getName().matches(".*-ext-.*")) {
       EventRecord.here(
               ServiceJarDiscovery.class, EventType.BOOTSTRAP_INIT_SERVICE_JAR, f.getName())
           .info();
       try {
         BindingFileSearch.INSTANCE.process(f);
       } catch (final Throwable e) {
         LOG.error(e.getMessage());
         continue;
       }
     }
   }
   for (String pathName : ClassPath.SYSTEM_CLASS_PATH.getClassPath().split(File.pathSeparator)) {
     File pathFile = new File(pathName);
     if (pathFile.isDirectory()) {
       try {
         BindingFileSearch.INSTANCE.process(pathFile);
       } catch (final Throwable e) {
         LOG.error(e.getMessage());
         continue;
       }
       ;
     }
   }
 }
コード例 #24
0
 /**
  * Marks an offset has committed. This method has side effects - it sets the internal state in
  * such a way that future calls to {@link #findNextCommitOffset()} will return offsets greater
  * than the offset specified, if any.
  *
  * @param committedOffset offset to be marked as committed
  */
 public void commit(OffsetAndMetadata committedOffset) {
   long numCommittedOffsets = 0;
   if (committedOffset != null) {
     final long oldCommittedOffset = this.committedOffset;
     numCommittedOffsets = committedOffset.offset() - this.committedOffset;
     this.committedOffset = committedOffset.offset();
     for (Iterator<KafkaSpoutMessageId> iterator = ackedMsgs.iterator(); iterator.hasNext(); ) {
       if (iterator.next().offset() <= committedOffset.offset()) {
         iterator.remove();
       } else {
         break;
       }
     }
     numUncommittedOffsets -= numCommittedOffsets;
     LOG.debug(
         "Committed offsets [{}-{} = {}] for topic-partition [{}]. [{}] uncommitted offsets across all topic partitions",
         oldCommittedOffset + 1,
         this.committedOffset,
         numCommittedOffsets,
         tp,
         numUncommittedOffsets);
   } else {
     LOG.debug(
         "Committed [{}] offsets for topic-partition [{}]. [{}] uncommitted offsets across all topic partitions",
         numCommittedOffsets,
         tp,
         numUncommittedOffsets);
   }
   LOG.trace("{}", this);
 }
コード例 #25
0
  /**
   * Reads the temporary results for non-Hive (non-Driver) commands to the resulting List of
   * strings.
   *
   * @param nLines number of lines read at once. If it is <= 0, then read all lines.
   */
  private List<String> readResults(int nLines) throws HiveSQLException {
    if (resultReader == null) {
      SessionState sessionState = getParentSession().getSessionState();
      File tmp = sessionState.getTmpOutputFile();
      try {
        resultReader = new BufferedReader(new FileReader(tmp));
      } catch (FileNotFoundException e) {
        LOG.error("File " + tmp + " not found. ", e);
        throw new HiveSQLException(e);
      }
    }
    List<String> results = new ArrayList<String>();

    for (int i = 0; i < nLines || nLines <= 0; ++i) {
      try {
        String line = resultReader.readLine();
        if (line == null) {
          // reached the end of the result file
          break;
        } else {
          results.add(line);
        }
      } catch (IOException e) {
        LOG.error("Reading temp results encountered an exception: ", e);
        throw new HiveSQLException(e);
      }
    }
    return results;
  }
コード例 #26
0
  /** 百付-手机支付退款回调处理 */
  @Action("/refund/upompRefundCallback")
  public String execute() {
    try {
      xml = PlusTools.getXml(this.getRequest());
      LOG.info("com.lvmama.pet.refundment.web.UpompRefundCallbackAction.execute() xml:" + xml);

      String result = renfedCallback();
      if (REFUND_SUCCESS.equalsIgnoreCase(result)) {
        boolean checkSign =
            PlusTools.checkSign(xml, PaymentConstant.getInstance().getProperty("UPOMP_CERT_PATH"));
        if (checkSign) {
          PlusTools.notifyXml(xml, "0000", getResponse());
          LOG.info(
              "upomp com.lvmama.pet.refundment.web.UpompRefundCallbackAction.execute():success...");
        } else {
          PlusTools.notifyXml(xml, "0001", getResponse());
          LOG.info(
              "upomp com.lvmama.pet.refundment.web.UpompRefundCallbackAction.execute():failed...");
        }
      }
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return "refund_success";
  }
コード例 #27
0
ファイル: HttpOutput.java プロジェクト: hypnoce/jetty.project
    @Override
    protected Action process() throws Exception {
      // Only return if EOF has previously been read and thus
      // a write done with EOF=true
      if (_eof) {
        if (LOG.isDebugEnabled()) LOG.debug("EOF of {}", this);
        // Handle EOF
        _in.close();
        closed();
        _channel.getByteBufferPool().release(_buffer);
        return Action.SUCCEEDED;
      }

      // Read until buffer full or EOF
      int len = 0;
      while (len < _buffer.capacity() && !_eof) {
        int r = _in.read(_buffer.array(), _buffer.arrayOffset() + len, _buffer.capacity() - len);
        if (r < 0) _eof = true;
        else len += r;
      }

      // write what we have
      _buffer.position(0);
      _buffer.limit(len);
      write(_buffer, _eof, this);
      return Action.SCHEDULED;
    }
コード例 #28
0
ファイル: NodeManager.java プロジェクト: baeeq/hadoop-20
    /**
     * Remove the node from the runnable indices
     *
     * @param node node to remove
     */
    public void deleteRunnable(ClusterNode node) {
      String host = node.getHost();

      if (LOG.isDebugEnabled()) {
        LOG.debug(node.getName() + " deleted from runnable list for type: " + type);
      }

      NodeContainer nodeContainer = hostToRunnableNodes.get(host);
      if (nodeContainer != null) {
        synchronized (nodeContainer) {
          if (nodeContainer.removeNode(node)) {
            /**
             * We are not removing the nodeContainer from runnable nodes map since we are
             * synchronizing operations with runnable indices on it
             */
            hostsWithRunnableNodes.decrementAndGet();
          }
        }
      }

      Node rack = node.hostNode.getParent();

      nodeContainer = rackToRunnableNodes.get(rack);
      if (nodeContainer != null) {
        synchronized (nodeContainer) {
          /**
           * We are not removing the nodeContainer from runnable nodes map since we are
           * synchronizing operations with runnable indices on it
           */
          nodeContainer.removeNode(node);
        }
      }
    }
コード例 #29
0
ファイル: ManagerThread.java プロジェクト: lilongthinker/MPS
    public void run() {
      try {
        while (true) {
          if (isInterrupted() || myClosed) {
            break;
          }
          processCommand(myCommandQueue.take());
        }

        if (myClosed) {
          List<IManagerCommand> unprocessed =
              ListSequence.fromList(new ArrayList<IManagerCommand>());
          myCommandQueue.drainTo(unprocessed);
          for (IManagerCommand command : ListSequence.fromList(unprocessed)) {
            try {
              command.cancel();
            } catch (Throwable t) {
              LOG.error("Command " + command + " threw an exception.", t);
            }
          }
        }
      } catch (InterruptedException ignore) {
        // do what?
      }
      LOG.debug("Thread " + this + " finished working.");
    }
コード例 #30
0
  /**
   * This method is to check the existence of budgetcategorycode in table.
   *
   * @param maintenanceDocument
   * @return
   */
  private boolean checkExistence(MaintenanceDocument maintenanceDocument) {

    boolean valid = true;
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "new maintainable is: " + maintenanceDocument.getNewMaintainableObject().getClass());
    }
    // shared by budgetcategorymapping & costelement
    // TODO : refactoring this - must have a better way to handle this sharing
    String budgetCategoryCode;
    if (maintenanceDocument.getNewMaintainableObject().getDataObject()
        instanceof BudgetCategoryMapping) {
      BudgetCategoryMapping budgetCategoryMapping =
          (BudgetCategoryMapping) maintenanceDocument.getNewMaintainableObject().getDataObject();
      budgetCategoryCode = budgetCategoryMapping.getBudgetCategoryCode();
    } else {
      CostElement costElement =
          (CostElement) maintenanceDocument.getNewMaintainableObject().getDataObject();
      budgetCategoryCode = costElement.getBudgetCategoryCode();
    }
    Map pkMap = new HashMap();
    pkMap.put("code", budgetCategoryCode);
    valid = checkExistenceFromTable(BudgetCategory.class, pkMap, "code", "Budget Category");

    return valid;
  }