Example #1
0
 static {
   _jspx_dependants = new java.util.HashMap<java.lang.String, java.lang.Long>(4);
   _jspx_dependants.put("/admin/../foot.jsp", Long.valueOf(1350283935831L));
   _jspx_dependants.put("/admin/../taglib.jsp", Long.valueOf(1345552994159L));
   _jspx_dependants.put("/admin/../top.jsp", Long.valueOf(1350305382989L));
   _jspx_dependants.put("/admin/left.jsp", Long.valueOf(1350298710763L));
 }
 public void addMemoryStatsToSnooper() {
   addData("memory_total", Long.valueOf(Runtime.getRuntime().totalMemory()));
   addData("memory_max", Long.valueOf(Runtime.getRuntime().maxMemory()));
   addData("memory_free", Long.valueOf(Runtime.getRuntime().freeMemory()));
   addData("cpu_cores", Integer.valueOf(Runtime.getRuntime().availableProcessors()));
   playerStatsCollector.addServerStatsToSnooper(this);
 }
Example #3
0
 // @Test
 public void numberFunctions() throws IOException {
   ServiceLocator locator = container;
   DataContext db = locator.resolve(DataContext.class);
   LocalDate ld = LocalDate.now();
   Clicked cl = new Clicked().setDate(ld);
   db.submit(cl);
   Query<Clicked> query = db.query(Clicked.class);
   String uri = cl.getURI();
   // TODO: produces incorrect queries
   boolean found1 =
       query.anyMatch(
           it ->
               Long.valueOf(3).equals(it.getBigint()) && it.getEn() == En.A
                   || it.getURI().toUpperCase().equals(uri));
   boolean found2 =
       query.anyMatch(
           it ->
               3L >= it.getBigint() && it.getDate() == LocalDate.now()
                   || Integer.valueOf(it.getURI()).equals(Integer.valueOf(uri)));
   boolean found3 =
       query.anyMatch(
           it ->
               Long.valueOf(3).equals(it.getBigint()) && it.getEn() == En.B
                   || it.getURI().toUpperCase().equals(uri));
   En b = En.B;
   boolean found4 = query.anyMatch(it -> it.getEn() == b || it.getURI().toUpperCase().equals(uri));
   Assert.assertTrue(found1);
   Assert.assertTrue(found2);
   Assert.assertTrue(found3);
   Assert.assertTrue(found4);
 }
 protected void initializeTimeStamps() {
   Field timeStampField = fieldMap.get(TIMESTAMP);
   startTimestamp = Long.valueOf(timeStampField.getMinValue());
   endTimestamp = Long.valueOf(timeStampField.getMaxValue());
   stepValue = Long.valueOf(timeStampField.getStepValue());
   populateTimestampsForSplits();
 }
  // 删除
  @RequestMapping(value = "/delete", method = RequestMethod.POST)
  @ResponseBody
  public Object del(String ids) {
    Map map = new HashMap();
    int result = 0;
    Collection collection = new ArrayList();
    for (String id : ids.split("&")) {
      List<ControlBaseInfo> controlBaseInfos =
          controlBaseInfoService.selectByBaseMer(Long.valueOf(id));

      if (controlBaseInfos.size() == 0) {
        result = baseMerService.deleteByPrimaryKey(Long.valueOf(id));
      } else {
        collection.addAll(controlBaseInfos);
      }
    }

    map.put("state", result);
    if (!collection.isEmpty()) {
      map.put(
          "controlBaseInfos",
          BeanUtil.getCollection2JSON(collection, "controlBaseInfos", "controlmername", true));
    }

    return map;
  }
Example #6
0
 /** Try to convert a string value into a numerical value. */
 private static Number createNumberFromStringValue(String value) throws NumberFormatException {
   final String suffix = value.substring(value.length() - 1);
   if ("L".equalsIgnoreCase(suffix)) {
     return Long.valueOf(value.substring(0, value.length() - 1));
   }
   if ("F".equalsIgnoreCase(suffix)) {
     return Float.valueOf(value.substring(0, value.length() - 1));
   }
   if ("D".equalsIgnoreCase(suffix)) {
     return Double.valueOf(value.substring(0, value.length() - 1));
   }
   try {
     return Integer.valueOf(value);
   } catch (NumberFormatException e) {
     // OK: Ignore exception...
   }
   try {
     return Long.valueOf(value);
   } catch (NumberFormatException e1) {
     // OK: Ignore exception...
   }
   try {
     return Double.valueOf(value);
   } catch (NumberFormatException e2) {
     // OK: Ignore exception...
   }
   throw new NumberFormatException(
       "Cannot convert string value '" + value + "' into a numerical value");
 }
 public RandomNumberGenerator() {
   this(
       Lists.newArrayList(
           Long.valueOf(1),
           Long.valueOf(Byte.MAX_VALUE),
           Long.valueOf(Short.MAX_VALUE),
           Long.valueOf(Integer.MAX_VALUE)));
 }
Example #8
0
 boolean isEnabled(long m) {
   if (enabledMechanisms != null) {
     return enabledMechanisms.contains(Long.valueOf(m));
   }
   if (disabledMechanisms != null) {
     return !disabledMechanisms.contains(Long.valueOf(m));
   }
   return true;
 }
Example #9
0
 public void insertOrderDeathInOrder(DVector DV, long lastStart, String msg, Tick tock) {
   if (DV.size() > 0)
     for (int i = 0; i < DV.size(); i++) {
       if (((Long) DV.elementAt(i, 1)).longValue() > lastStart) {
         DV.insertElementAt(i, Long.valueOf(lastStart), msg, tock);
         return;
       }
     }
   DV.addElement(Long.valueOf(lastStart), msg, tock);
 }
  @Test
  public void handlesRequest() throws Exception {
    handler.handleMessage(
        "{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": 1}");

    assertEquals(1, listener.requests.size());
    assertEquals(0, listener.responses.size());
    assertEquals(0, listener.notifications.size());
    assertEquals(0, listener.unknownMessages.size());

    assertContainsValue(listener.requests, field("id", Long.valueOf(1)), true);
    assertContainsValue(listener.requests, field("method", "subtract"), true);
    assertContainsValue(listener.requests, field("jsonrpc", "2.0"), true);
    assertContainsValue(
        listener.requests,
        field(
            "params",
            new ArrayList<Long>() {
              {
                add(Long.valueOf(42));
                add(Long.valueOf(23));
              }
            }),
        true);

    assertContainsKey(listener.requests, "result", false);
    assertContainsKey(listener.requests, "error", false);

    handler.handleMessage(
        "{\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": {\"subtrahend\": 23, \"minuend\": 42}, \"id\": 3}");
    assertEquals(2, listener.requests.size());
    assertEquals(0, listener.responses.size());
    assertEquals(0, listener.notifications.size());
    assertEquals(0, listener.unknownMessages.size());

    assertContainsValue(listener.requests, field("id", Long.valueOf(3)), true);
    assertContainsValue(listener.requests, field("method", "subtract"), true);
    assertContainsValue(listener.requests, field("jsonrpc", "2.0"), true);
    assertContainsValue(
        listener.requests,
        field(
            "params",
            new HashMap<String, Long>() {
              {
                put("minuend", Long.valueOf(42));
                put("subtrahend", Long.valueOf(23));
              }
            }),
        true);

    assertContainsKey(listener.requests, "result", false);
    assertContainsKey(listener.requests, "error", false);
  }
 public void occurred(String operationName) {
   if (this.profileWeight < SessionProfiler.NORMAL) {
     return;
   }
   synchronized (this.operationTimings) {
     Long occurred = (Long) this.operationTimings.get(operationName);
     if (occurred == null) {
       this.operationTimings.put(operationName, Long.valueOf(1));
     } else {
       this.operationTimings.put(operationName, Long.valueOf(occurred.longValue() + 1));
     }
   }
 }
Example #12
0
  public void solve() {
    while (input.hasNext()) {
      String s = input.nextLine();
      s = s.replaceAll("[0\\.\\)]", "");
      String[] t = s.split("\\(");
      long a = Long.valueOf(t[0]);
      long b = Long.valueOf(t[1]);

      long x = a * ((long) pow(10, t[1].length()) - 1) + b;
      long y = ((long) pow(10, t[1].length()) - 1) * (long) pow(10, t[0].length());
      System.out.println(x);
      System.out.println(y);
      System.out.printf((x / gcd(x, y)) + "/" + (y / gcd(x, y)));
    }
  }
Example #13
0
 public static Number toWrapper(long l) {
   if (l >= Integer.MIN_VALUE && l <= Integer.MAX_VALUE) {
     return toWrapper((int) l);
   } else {
     return Long.valueOf(l);
   }
 }
Example #14
0
 @SuppressWarnings("LockAcquiredButNotSafelyReleased")
 protected void handleLock(String[] args) {
   String lockStr = args[0];
   String key = args[1];
   Lock lock = hazelcast.getLock(key);
   if (lockStr.equalsIgnoreCase("lock")) {
     lock.lock();
     println("true");
   } else if (lockStr.equalsIgnoreCase("unlock")) {
     lock.unlock();
     println("true");
   } else if (lockStr.equalsIgnoreCase("trylock")) {
     String timeout = args.length > 2 ? args[2] : null;
     if (timeout == null) {
       println(lock.tryLock());
     } else {
       long time = Long.valueOf(timeout);
       try {
         println(lock.tryLock(time, TimeUnit.SECONDS));
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
   }
 }
 private void populateTimestampsForSplits() {
   timestampsPerSplit = new HashMap<Long, List<Long>>();
   for (int i = 0; i < options.getNumberOfFileSplits(); i++) {
     List<Long> timestamps = getTimestampsPerSplit(i);
     timestampsPerSplit.put(Long.valueOf(i), timestamps);
   }
 }
Example #16
0
    private static List linkGlobalPropertyList(String name) {
        Map<String, String> map = getGlobalPropertiesStartWith(name);
        List<String> ret = new ArrayList<String>(map.size());
        if (map.isEmpty()) {
            return ret;
        }

        List<String> orderedKeys = new ArrayList<String>();
        orderedKeys.addAll(map.keySet());
        Collections.sort(orderedKeys);

        for (String key : orderedKeys) {
            String index = StringDSL.stripStart(key, name).trim();
            try {
                Long.valueOf(index);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(String.format("[Illegal List Definition] %s is an invalid list key" +
                        " definition, the last character must be a number, for example %s1. %s is not a number", key, key, index));

            }

            ret.add(map.get(key));
        }

        return ret;
    }
Example #17
0
    private HttpCachingConfig(SolrConfig conf) {

      never304 = conf.getBool(CACHE_PRE + "@never304", false);

      etagSeed = conf.get(CACHE_PRE + "@etagSeed", "Solr");

      lastModFrom = LastModFrom.parse(conf.get(CACHE_PRE + "@lastModFrom", "openTime"));

      cacheControlHeader = conf.get(CACHE_PRE + "cacheControl", null);

      Long tmp = null; // maxAge
      if (null != cacheControlHeader) {
        try {
          final Matcher ttlMatcher = MAX_AGE.matcher(cacheControlHeader);
          final String ttlStr = ttlMatcher.find() ? ttlMatcher.group(1) : null;
          tmp = (null != ttlStr && !"".equals(ttlStr)) ? Long.valueOf(ttlStr) : null;
        } catch (Exception e) {
          log.warn(
              "Ignoring exception while attempting to "
                  + "extract max-age from cacheControl config: "
                  + cacheControlHeader,
              e);
        }
      }
      maxAge = tmp;
    }
Example #18
0
  protected List<PingData> read(InputStream in) {
    List<PingData> retval = null;
    try {
      while (true) {
        try {
          String name_str = Util.readToken(in);
          String uuid_str = Util.readToken(in);
          String addr_str = Util.readToken(in);
          String coord_str = Util.readToken(in);
          if (name_str == null || uuid_str == null || addr_str == null || coord_str == null) break;

          UUID uuid = null;
          try {
            long tmp = Long.valueOf(uuid_str);
            uuid = new UUID(0, tmp);
          } catch (Throwable t) {
            uuid = UUID.fromString(uuid_str);
          }

          PhysicalAddress phys_addr = new IpAddress(addr_str);
          boolean is_coordinator = coord_str.trim().equals("T") || coord_str.trim().equals("t");

          if (retval == null) retval = new ArrayList<>();
          retval.add(new PingData(uuid, true, name_str, phys_addr).coord(is_coordinator));
        } catch (Throwable t) {
          log.error(Util.getMessage("FailedReadingLineOfInputStream"), t);
        }
      }
      return retval;
    } finally {
      Util.close(in);
    }
  }
Example #19
0
    private static void writePidFile() throws IOException {
        if (CoreGlobalProperty.UNIT_TEST_ON) {
            return;
        }

        File pidFile = new File(CoreGlobalProperty.PID_FILE_PATH);
        if (pidFile.exists()) {
            String pidStr = FileUtils.readFileToString(pidFile);
            try {
                long pid = Long.valueOf(pidStr);
                String processProcDir = String.format("/proc/%s", pid);
                File processProcDirFile = new File(processProcDir);
                if (processProcDirFile.exists()) {
                    throw new CloudRuntimeException(String.format("pid file[%s] exists and the process[pid:%s] that the pid file points to is still running", CoreGlobalProperty.PID_FILE_PATH, pidStr));
                }
            } catch (NumberFormatException e) {
                logger.warn(String.format("pid file[%s] includes an invalid pid[%s] that is not a long number, ignore it",
                        CoreGlobalProperty.PID_FILE_PATH, pidStr));
            }

            logger.info(String.format("stale pid file[%s], ignore it", CoreGlobalProperty.PID_FILE_PATH));
        }

        pidFile.deleteOnExit();
        String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
        FileUtils.writeStringToFile(pidFile, pid);
    }
Example #20
0
 private Set<Long> parseMechanisms(String keyword) throws IOException {
   checkDup(keyword);
   Set<Long> mechs = new HashSet<Long>();
   parseEquals();
   parseOpenBraces();
   while (true) {
     int token = nextToken();
     if (isCloseBraces(token)) {
       break;
     }
     if (token == TT_EOL) {
       continue;
     }
     if (token != TT_WORD) {
       throw excToken("Expected mechanism, read");
     }
     long mech = parseMechanism(st.sval);
     mechs.add(Long.valueOf(mech));
   }
   if (DEBUG) {
     System.out.print("mechanisms: [");
     for (Long mech : mechs) {
       System.out.print(Functions.getMechanismName(mech));
       System.out.print(", ");
     }
     System.out.println("]");
   }
   return mechs;
 }
 protected Cache getGatewayKeyCache() {
   String apimGWCacheExpiry =
       ServiceReferenceHolder.getInstance()
           .getAPIManagerConfiguration()
           .getFirstProperty(APIConstants.TOKEN_CACHE_EXPIRY);
   if (!gatewayKeyCacheInit) {
     gatewayKeyCacheInit = true;
     if (apimGWCacheExpiry != null) {
       return APIUtil.getCache(
           APIConstants.API_MANAGER_CACHE_MANAGER,
           APIConstants.GATEWAY_KEY_CACHE_NAME,
           Long.parseLong(apimGWCacheExpiry),
           Long.parseLong(apimGWCacheExpiry));
     } else {
       long defaultCacheTimeout =
           Long.valueOf(
                   ServerConfiguration.getInstance()
                       .getFirstProperty(APIConstants.DEFAULT_CACHE_TIMEOUT))
               * 60;
       return APIUtil.getCache(
           APIConstants.API_MANAGER_CACHE_MANAGER,
           APIConstants.GATEWAY_KEY_CACHE_NAME,
           defaultCacheTimeout,
           defaultCacheTimeout);
     }
   }
   return Caching.getCacheManager(APIConstants.API_MANAGER_CACHE_MANAGER)
       .getCache(APIConstants.GATEWAY_KEY_CACHE_NAME);
 }
Example #22
0
 private static Object parseValue(String value, Prop p, Class type) {
   Object v = value;
   if (type.isArray()) {
     StringTokenizer st = new StringTokenizer(value, ",");
     Class ctype = type.getComponentType();
     v = Array.newInstance(ctype, st.countTokens());
     for (int i = 0; st.hasMoreTokens(); i++)
       Array.set(v, i, parseValue(st.nextToken(), p, ctype));
   } else if (type == boolean.class) {
     v = Boolean.valueOf(value);
   } else if (type == double.class) {
     v = Double.valueOf(value);
   } else if (type == int.class) {
     v = Integer.valueOf(value);
   } else if (p.field.isAnnotationPresent(TimeIntervalProp.class)) {
     if (value.endsWith("s")) {
       v = (long) (Double.parseDouble(value.substring(0, value.length() - 1)) * SEC);
     } else if (value.endsWith("m")) {
       v = (long) (Double.parseDouble(value.substring(0, value.length() - 1)) * MIN);
     } else {
       v = Long.valueOf(value);
     }
   }
   return v;
 }
 /** Log the results to the session's log (System.out). */
 public void dumpResults() {
   this.lastDumpTime = System.currentTimeMillis();
   StringWriter writer = new StringWriter();
   writer.write("\nPerformance Monitor:");
   writer.write(String.valueOf(this.lastDumpTime));
   writer.write("\nOperation\tValue (ns)\n");
   Set<String> operations = new TreeSet<String>(this.operationTimings.keySet());
   NumberFormat formater = NumberFormat.getInstance();
   for (String operation : operations) {
     Object value = this.operationTimings.get(operation);
     if (value == null) {
       value = Long.valueOf(0);
     }
     writer.write(operation);
     writer.write("\t");
     if (value instanceof Long) {
       writer.write(formater.format(value));
     } else {
       writer.write(value.toString());
     }
     writer.write("\n");
   }
   try {
     this.session.getLog().write(writer.toString());
     this.session.getLog().flush();
   } catch (IOException error) {
     // ignore
   }
 }
  @Test(timeout = 1000)
  public void testSameSourceMultipleIterators() {
    TestScheduler scheduler = new TestScheduler();

    NbpBlockingObservable<Long> source =
        NbpObservable.interval(1, TimeUnit.SECONDS, scheduler).take(10).toBlocking();

    Iterable<Long> iter = source.latest();

    for (int j = 0; j < 3; j++) {
      Iterator<Long> it = iter.iterator();

      // only 9 because take(10) will immediately call onCompleted when receiving the 10th item
      // which onCompleted will overwrite the previous value
      for (int i = 0; i < 9; i++) {
        scheduler.advanceTimeBy(1, TimeUnit.SECONDS);

        Assert.assertEquals(true, it.hasNext());

        Assert.assertEquals(Long.valueOf(i), it.next());
      }

      scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
      Assert.assertEquals(false, it.hasNext());
    }
  }
Example #25
0
 public void removeRelation(InternalRelation relation) {
   Preconditions.checkArgument(!relation.isRemoved());
   relation = relation.it();
   // Delete from Vertex
   for (int i = 0; i < relation.getLen(); i++) {
     relation.getVertex(i).removeRelation(relation);
   }
   // Update transaction data structures
   if (relation.isNew()) {
     addedRelations.remove(relation);
     if (isVertexIndexProperty(relation)) newVertexIndexEntries.remove((TitanProperty) relation);
   } else {
     Preconditions.checkArgument(relation.isLoaded());
     if (deletedRelations == EMPTY_DELETED_RELATIONS) {
       if (config.isSingleThreaded()) {
         deletedRelations = new HashMap<Long, InternalRelation>();
       } else {
         synchronized (this) {
           if (deletedRelations == EMPTY_DELETED_RELATIONS)
             deletedRelations = new ConcurrentHashMap<Long, InternalRelation>();
         }
       }
     }
     deletedRelations.put(Long.valueOf(relation.getID()), relation);
   }
 }
  /**
   * @param clusterId
   * @param hostName
   */
  @Transactional
  public void removeHost(final long clusterId, String hostName) {

    populateCache();

    Set<HostConfigMapping> set = hostConfigMappingByHost.get(hostName);

    // Remove from cache items with clusterId
    CollectionUtils.filter(
        set,
        new Predicate() {

          @Override
          public boolean evaluate(Object arg0) {
            return !((HostConfigMapping) arg0).getClusterId().equals(clusterId);
          }
        });

    // delete from db
    TypedQuery<HostConfigMappingEntity> query =
        entityManagerProvider
            .get()
            .createQuery(
                "SELECT entity FROM HostConfigMappingEntity entity "
                    + "WHERE entity.clusterId = ?1 AND entity.hostName = ?2",
                HostConfigMappingEntity.class);

    List<HostConfigMappingEntity> list =
        daoUtils.selectList(query, Long.valueOf(clusterId), hostName);

    for (HostConfigMappingEntity entity : list) {
      entityManagerProvider.get().remove(entity);
    }
  }
Example #27
0
 /**
  * Helper method used to get default value for wrappers used for primitive types (0 for Integer
  * etc)
  *
  * @since 1.6.1
  */
 public static Object defaultValue(Class<?> cls) {
   if (cls == Integer.TYPE) {
     return Integer.valueOf(0);
   }
   if (cls == Long.TYPE) {
     return Long.valueOf(0L);
   }
   if (cls == Boolean.TYPE) {
     return Boolean.FALSE;
   }
   if (cls == Double.TYPE) {
     return Double.valueOf(0.0);
   }
   if (cls == Float.TYPE) {
     return Float.valueOf(0.0f);
   }
   if (cls == Byte.TYPE) {
     return Byte.valueOf((byte) 0);
   }
   if (cls == Short.TYPE) {
     return Short.valueOf((short) 0);
   }
   if (cls == Character.TYPE) {
     return '\0';
   }
   throw new IllegalArgumentException("Class " + cls.getName() + " is not a primitive type");
 }
Example #28
0
 @Test
 public void testSetGet() {
   e = openEngine();
   long recid = e.put((long) 10000, Serializer.LONG);
   Long s2 = e.get(recid, Serializer.LONG);
   assertEquals(s2, Long.valueOf(10000));
   e.close();
 }
Example #29
0
  public long headersNumber(String key, long defaultValue) {
    long value = defaultValue;
    String string = null;
    if (headers != null) string = headers.get(key);
    if (string != null) value = Long.valueOf(string);

    return value;
  }
 @Override
 protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock)
     throws SAXException {
   final String revision = attributes.getValue("revision");
   if (!StringUtil.isEmpty(revision)) {
     status.setCommittedRevision(SVNRevision.create(Long.valueOf(revision)));
   }
 }