CheckinMemoryDao() {

    Checkin checkin =
        new Checkin(
            Long.toString(counter.incrementAndGet()),
            "Greg",
            "CVG",
            (System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)));
    contentProvider.put(checkin.getId(), checkin);

    checkin =
        new Checkin(
            Long.toString(counter.incrementAndGet()),
            "Greg",
            "ATL",
            (System.currentTimeMillis() - TimeUnit.DAYS.toMillis(2)));
    contentProvider.put(checkin.getId(), checkin);

    checkin =
        new Checkin(
            Long.toString(counter.incrementAndGet()),
            "Noah",
            "SFO",
            (System.currentTimeMillis() - TimeUnit.DAYS.toMillis(3)));
    contentProvider.put(checkin.getId(), checkin);

    checkin =
        new Checkin(
            Long.toString(counter.incrementAndGet()),
            "Noah",
            "ATL",
            (System.currentTimeMillis() - TimeUnit.DAYS.toMillis(4)));
    contentProvider.put(checkin.getId(), checkin);
  }
  public void produceCpuEvents(NodePojo node)
      throws ExecutionException, InterruptedException, IOException {
    ChartPrettyRandomGenerator genUser = cpuUserGenerator.get(node.getIpAddress());
    if (genUser == null) {
      genUser = new ChartPrettyRandomGenerator(true, 80, 20);
      cpuUserGenerator.put(node.getIpAddress(), genUser);
    }
    ChartPrettyRandomGenerator genSys = cpuSysGenerator.get(node.getIpAddress());
    if (genSys == null) {
      genSys = new ChartPrettyRandomGenerator(true, 80, 20);
      cpuSysGenerator.put(node.getIpAddress(), genSys);
    }
    List<SamplePojo> samples = new ArrayList<SamplePojo>();

    long userCpu = Long.parseLong(genUser.getNextValue());
    long systemCpu = Long.parseLong(genSys.getNextValue());
    long idleCpu;

    if (userCpu + systemCpu > 100) {
      systemCpu = 100 - userCpu;
      idleCpu = 0;
    } else {
      idleCpu = 100 - (userCpu + systemCpu);
    }

    samples.add(new SamplePojo("User", Long.toString(userCpu)));
    samples.add(new SamplePojo("Sys", Long.toString(systemCpu)));
    samples.add(new SamplePojo("Idle", Long.toString(idleCpu)));

    listener.publishEvent(
        new EventPojo(node.getIpAddress(), symTime, TopLevelConst.CPU_LINE_CHART_DATA, samples));
  }
Esempio n. 3
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub

    Scanner in = new Scanner(System.in);
    Hashtable numbers = new Hashtable();

    N = in.nextInt();
    K = in.nextLong();

    long[] arr = new long[N];
    for (int i = 0; i < N; i++) {
      arr[i] = in.nextLong();
      numbers.put(Long.toString(arr[i]), arr[i]);
    }

    result = 0;

    for (int i = 0; i < N; i++) {
      long tmp = 0, tmp2 = 0;
      tmp = arr[i] + K;
      try {
        tmp2 = (Long) numbers.get(Long.toString(tmp));
        result++;
      } catch (Exception ex) {

      }
    }

    System.out.println(result);
  }
 @Override
 @SuppressWarnings("unchecked")
 public Conversation create(Conversation conv) {
   final Long id = getId(conv);
   if (template
           .opsForValue()
           .get(
               KeyUtils.conversationProductIdAndVisitorToken(
                   conv.getTopic().getProductId(), conv.getVisitor()))
       != null) {
     return findBy(id);
   }
   conv.setId(id);
   template.opsForHash().put(getIdKey(id), "id", id.toString());
   template.opsForHash().put(getIdKey(id), "topic", conv.getTopic().getId().toString());
   template.opsForHash().put(getIdKey(id), "visitor", conv.getVisitor());
   template.opsForHash().put(getIdKey(id), "visitorName", conv.getVisitorName());
   template
       .opsForHash()
       .put(getIdKey(id), "customerServiceUser", conv.getCustomerServiceUsername());
   template.opsForHash().put(getIdKey(id), "status", conv.getStatus().toString());
   template
       .opsForHash()
       .put(getIdKey(id), "createDate", String.valueOf(conv.getCreateDate().getTime()));
   template
       .opsForValue()
       .set(
           KeyUtils.conversationProductIdAndVisitorToken(
               conv.getTopic().getProductId(), conv.getVisitor()),
           id.toString());
   return conv;
 }
Esempio n. 5
0
 private boolean auto(String operation) {
   long startTime = System.currentTimeMillis();
   System.out.println("Operation: " + operation + "...");
   HibernateEntityManagerFactory emf = null;
   EntityManager em = null;
   try {
     Map<String, String> map = getPeristencePropertiesFixedMap();
     if (operation != null) {
       map.put("hibernate.hbm2ddl.auto", operation);
     }
     if (operation.equals("update")) {
       if (getDriver().equals(TestStation.Driver.derby)) {
         String url = map.get("hibernate.connection.url");
         if (!url.contains("create=true")) {
           url += ";create=true";
         }
         //                    if (!url.contains("logDevice=")) {
         //                        url += ";logDevice=" + getUserHome() + File.separator +
         // ".jtstand";
         //                    }
         map.put("hibernate.connection.url", url);
       }
     }
     emf =
         (HibernateEntityManagerFactory)
             Persistence.createEntityManagerFactory(getTestProject().getPun(), map);
     //            emf.getSessionFactory().getAllClassMetadata();
     //            System.out.println(emf.getSessionFactory().getAllClassMetadata());
     em = emf.createEntityManager();
     em.getTransaction().begin();
     em.getTransaction().commit();
     //            System.out.println("Closing entity manager");
     em.close();
     //            System.out.println("Closing entity manager factory");
     emf.close();
     System.out.println(
         "Database "
             + operation
             + " operation succeeded in "
             + Long.toString(System.currentTimeMillis() - startTime)
             + "ms");
     return true;
   } catch (Exception ex) {
     ex.printStackTrace();
     System.out.println(ex.getMessage());
     if (em != null && em.isOpen()) {
       em.close();
     }
     if (emf != null && emf.isOpen()) {
       emf.close();
     }
   }
   System.out.println(
       "Database "
           + operation
           + " operation failed in "
           + Long.toString(System.currentTimeMillis() - startTime)
           + "ms");
   return false;
 }
Esempio n. 6
0
  public String toString() {
    String s;
    if (nodeID != null && nodeID.length() > 0) {
      s = nodeID + " -- " + Long.toString(getSerialNumber(), 16);
    } else {
      s = Long.toString(getSerialNumber(), 16);
    }

    if (isConnected()) {
      s = "Connected " + s;
    }
    return s;
  }
 public String toString() {
   String ret =
       "<CFBamPopDepByRelationIdx"
           + " RequiredRelationTenantId="
           + "\""
           + Long.toString(getRequiredRelationTenantId())
           + "\""
           + " RequiredRelationId="
           + "\""
           + Long.toString(getRequiredRelationId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFDbTestBoolTypeBySchemaIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredSchemaDefId="
           + "\""
           + Long.toString(getRequiredSchemaDefId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamTimeColByTableIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredTableId="
           + "\""
           + Long.toString(getRequiredTableId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamClearTopDepByContTblIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredContTableId="
           + "\""
           + Long.toString(getRequiredContTableId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFCrmContactURLPKey"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredContactURLId="
           + "\""
           + Long.toString(getRequiredContactURLId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFFreeSwitchPbxIvrMenuEntryByMenuIdIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredMenuId="
           + "\""
           + Long.toString(getRequiredMenuId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFDbTestValueByScopeIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredScopeId="
           + "\""
           + Long.toString(getRequiredScopeId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamScopePKey"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFCrmMemoTagByTagIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredTagId="
           + "\""
           + Long.toString(getRequiredTagId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFAsteriskClusterId64Gen"
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + ", SliceId=\""
           + Short.toString(getRequiredSliceId())
           + "\""
           + ", NextId=\""
           + Long.toString(nextId)
           + "\"/>";
   return (ret);
 }
Esempio n. 17
0
 private ContentValues tranValues(Transaction trans) {
   ContentValues newValue = new ContentValues();
   newValue.put("acct_id", trans.acct.ID);
   newValue.put("trans_id", trans.transID);
   newValue.put("serv_trans_id", trans.servTransID);
   newValue.put("type", trans.type);
   newValue.put("amt", trans.amt);
   newValue.put(
       "post_date", trans.postDate == null ? null : Long.toString(trans.postDate.getTime()));
   newValue.put(
       "init_date", trans.initDate == null ? null : Long.toString(trans.initDate.getTime()));
   newValue.put(
       "avail_date", trans.availDate == null ? null : Long.toString(trans.availDate.getTime()));
   return newValue;
 }
Esempio n. 18
0
  private String buildSystemIdentifierForImportPaymentOperation(ExchangeContext ctx) {
    String bik = getStringFromContext(ctx, "paymentBIK", "");
    Long branchId = (Long) ctx.getVariable("paymentBankBranch");
    Date paymentDate = (Date) ctx.getVariable("paymentDate");
    if (ctx.getVariable("paymentId") == null) {
      throw new RuntimeException(
          "Уникальный номер платежа внутри отделения в теч. дня должен быть заполнен");
    }
    Long paymentId = (Long) ctx.getVariable("paymentId");

    String branchPart = leftPad(branchId.toString(), 6, '0');
    String datePaymentPart = new SimpleDateFormat("yyMMdd").format(paymentDate);
    String paymentIdPart = leftPad(paymentId.toString(), 10, '0');
    return "1" + bik + branchPart + datePaymentPart + paymentIdPart;
  }
Esempio n. 19
0
  public void verifySequences(long fromOffset, long toOffset) throws Exception {
    populateTopicPartitionToOffsetToFiles();
    filterOffsets(fromOffset, toOffset);

    Iterator iterator = mTopicPartitionToOffsetToFiles.entrySet().iterator();
    while (iterator.hasNext()) {
      TreeSet<Long> offsets = new TreeSet<Long>();
      Map.Entry entry = (Map.Entry) iterator.next();
      TopicPartition topicPartition = (TopicPartition) entry.getKey();
      SortedMap<Long, HashSet<LogFilePath>> offsetToFiles =
          (SortedMap<Long, HashSet<LogFilePath>>) entry.getValue();
      for (HashSet<LogFilePath> logFilePaths : offsetToFiles.values()) {
        for (LogFilePath logFilePath : logFilePaths) {
          getOffsets(logFilePath, offsets);
        }
      }
      long lastOffset = -2;
      for (Long offset : offsets) {
        if (lastOffset != -2) {
          assert lastOffset + 1 == offset
              : Long.toString(offset)
                  + " + 1 == "
                  + offset
                  + " for topic "
                  + topicPartition.getTopic()
                  + " partition "
                  + topicPartition.getPartition();
        }
        lastOffset = offset;
      }
    }
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindPopSubDep1ContPopTopDepId.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamPopSubDep1Obj) {
      long contPopTopDepId = ((ICFBamPopSubDep1Obj) genDef).getRequiredContPopTopDepId();
      ret = Long.toString(contPopTopDepId);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), "expandBody", "genContext.getGenDef()", genDef, "ICFBamPopSubDep1Obj");
    }

    return (ret);
  }
  @Override
  public void loadIndex() {
    String indexFile = _options._indexPrefix + "/statistics";

    System.out.println("Load index from: " + indexFile);
    try {
      BufferedReader reader = new BufferedReader(new FileReader(indexFile));
      String line;
      int count = 0;
      while ((line = reader.readLine()) != null) {
        ++count;
        if (count == 1) _numDocs = Integer.parseInt(line);
        if (count == 2) _totalTermFrequency = Integer.parseInt(line);
      }
      reader.close();
      System.out.println(
          "Indexed "
              + Integer.toString(_numDocs)
              + " docs with "
              + Long.toString(_totalTermFrequency)
              + " terms.");
    } catch (Exception e) {

    }
  }
 @Override
 protected Map<Field, String> determineOverriddenValues(
     Long startTime, String symbolName, PriceSet priceSet) {
   Map<Field, String> overriddenValues = new HashMap<Field, String>();
   Field symbolField = fieldMap.get(SYMBOL);
   overriddenValues.put(symbolField, symbolName);
   Field timestampField = fieldMap.get(TIMESTAMP);
   String timeStamp = getValueWithPadding(Long.toString(startTime), timestampField);
   overriddenValues.put(timestampField, timeStamp);
   Field bidPrice = fieldMap.get(BID_PRICE);
   double randomBoundForPrice = 20.0d;
   double randomBoundForQuantity = 50.0d;
   String bidPriceValue = getRandomValue(priceSet.bidPrice, randomBoundForPrice, bidPrice);
   overriddenValues.put(bidPrice, bidPriceValue);
   Field bidQuantity = fieldMap.get(BID_SIZE);
   String bidQuantityValue =
       getRandomValue(priceSet.bidQuantity, randomBoundForQuantity, bidQuantity);
   overriddenValues.put(bidQuantity, bidQuantityValue);
   Field askPrice = fieldMap.get(ASK_PRICE);
   String askPriceValue = getRandomValue(priceSet.askPrice, randomBoundForPrice, askPrice);
   overriddenValues.put(askPrice, askPriceValue);
   Field askQuantity = fieldMap.get(ASK_SIZE);
   String askQuantityValue =
       getRandomValue(priceSet.askQuantity, randomBoundForQuantity, askQuantity);
   overriddenValues.put(askQuantity, askQuantityValue);
   return overriddenValues;
 }
Esempio n. 23
0
  public synchronized void addWord(final PwmSession pwmSession, final String word) {
    if (status != STATUS.OPEN) {
      return;
    }

    final String addWord = normalizeWord(word);

    if (addWord == null) {
      return;
    }

    final long startTime = System.currentTimeMillis();

    try {
      final String hashedWord = hashWord(addWord);

      final boolean preExisting = localDB.contains(WORDS_DB, hashedWord);
      localDB.put(WORDS_DB, hashedWord, Long.toString(System.currentTimeMillis()));

      {
        final StringBuilder logOutput = new StringBuilder();
        logOutput.append(preExisting ? "updated" : "added").append(" word");
        logOutput
            .append(" (")
            .append(new TimeDuration(System.currentTimeMillis(), startTime).asCompactString())
            .append(")");
        logOutput.append(" (").append(this.size()).append(" total words)");
        LOGGER.trace(logOutput.toString());
      }
    } catch (Exception e) {
      LOGGER.warn(pwmSession, "error adding word to global history list: " + e.getMessage());
    }
  }
Esempio n. 24
0
  /** {@inheritDoc} */
  public String getNextSubAwardCode() {
    Long nextAwardNumber =
        sequenceAccessorService.getNextAvailableSequenceNumber(
            Constants.SUBAWARD_SEQUENCE_SUBAWARD_CODE);

    return nextAwardNumber.toString();
  }
Esempio n. 25
0
  public String getName(Object info) {

    StringBuffer name = new StringBuffer();

    if (getCustomerId() != null) {
      name.append(m_Customer.toString());
      name.append(" - ");
    }

    if (info == null) {
      if (m_iTicketId == 0) {
        name.append(
            "("
                + m_dateformat.format(m_dDate)
                + " "
                + Long.toString(m_dDate.getTime() % 1000)
                + ")");
      } else {
        name.append(Integer.toString(m_iTicketId));
      }
    } else {
      name.append(info.toString());
    }

    return name.toString();
  }
Esempio n. 26
0
 /** @return nick(id) */
 public String getNickAndId() {
   StringBuffer sb = new StringBuffer(getNick());
   sb.append('(');
   sb.append(Long.toString(getId()));
   sb.append(')');
   return sb.toString();
 }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindUuidGenDispenserId.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamUuidGenObj) {
      Long dispenserId = ((ICFBamUuidGenObj) genDef).getOptionalDispenserId();
      if (dispenserId == null) {
        ret = null;
      } else {
        ret = dispenserId.toString();
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), "expandBody", "genContext.getGenDef()", genDef, "ICFBamUuidGenObj");
    }

    return (ret);
  }
Esempio n. 28
0
  /**
   * Saves the last status for all accounts. This information is used on loging. Each time user logs
   * in he's logged with the same status as he was the last time before closing the application.
   *
   * @param protocolProvider the protocol provider to save status information for
   * @param statusName the name of the status to save
   */
  private void saveStatusInformation(ProtocolProviderService protocolProvider, String statusName) {
    ConfigurationService configService = GuiActivator.getConfigurationService();

    String prefix = "net.java.sip.communicator.impl.gui.accounts";

    List<String> accounts = configService.getPropertyNamesByPrefix(prefix, true);

    boolean savedAccount = false;

    for (String accountRootPropName : accounts) {
      String accountUID = configService.getString(accountRootPropName);

      if (accountUID.equals(protocolProvider.getAccountID().getAccountUniqueID())) {

        configService.setProperty(accountRootPropName + ".lastAccountStatus", statusName);

        savedAccount = true;
      }
    }

    if (!savedAccount) {
      String accNodeName = "acc" + Long.toString(System.currentTimeMillis());

      String accountPackage = "net.java.sip.communicator.impl.gui.accounts." + accNodeName;

      configService.setProperty(
          accountPackage, protocolProvider.getAccountID().getAccountUniqueID());

      configService.setProperty(accountPackage + ".lastAccountStatus", statusName);
    }
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFFreeSwitchMssCFBindFSSFProfileAliasFSSFProfileId.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFFreeSwitchFSSFProfileAliasObj) {
      long fSSFProfileId = ((ICFFreeSwitchFSSFProfileAliasObj) genDef).getRequiredFSSFProfileId();
      ret = Long.toString(fSSFProfileId);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(),
              "expandBody",
              "genContext.getGenDef()",
              genDef,
              "ICFFreeSwitchFSSFProfileAliasObj");
    }

    return (ret);
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindInt64DefMinValue.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamInt64DefObj) {
      Long minValue = ((ICFBamInt64DefObj) genDef).getOptionalMinValue();
      if (minValue == null) {
        ret = null;
      } else {
        ret = minValue.toString();
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), "expandBody", "genContext.getGenDef()", genDef, "ICFBamInt64DefObj");
    }

    return (ret);
  }