List of usage examples for java.math BigInteger toString
public String toString()
From source file:org.calrissian.accumulorecipes.featurestore.support.StatsCombiner.java
@Override public Value reduce(Key key, Iterator<Value> iter) { long min = Long.MAX_VALUE; long max = Long.MIN_VALUE; long sum = 0; long count = 0; BigInteger sumSquare = BigInteger.valueOf(0); while (iter.hasNext()) { String stats[] = iter.next().toString().split(","); if (stats.length == 1) { long val = parseLong(stats[0]); min = min(val, min); max = max(val, max); sum += val; count += 1;// w w w . j a v a2 s. c o m sumSquare = sumSquare.add(BigInteger.valueOf(val * val)); } else { min = min(parseLong(stats[0]), min); max = max(parseLong(stats[1]), max); sum += parseLong(stats[2]); count += parseLong(stats[3]); sumSquare = sumSquare.add(new BigInteger(stats[4])); } } String ret = join(",", Long.toString(min), Long.toString(max), Long.toString(sum), Long.toString(count), sumSquare.toString()); return new Value(ret.getBytes()); }
From source file:com.spotify.reaper.cassandra.JmxProxy.java
public int triggerRepairPre2dot1(RepairParallelism repairParallelism, String keyspace, Collection<String> columnFamilies, BigInteger beginToken, BigInteger endToken) { // Cassandra 1.2 and 2.0 compatibility if (repairParallelism.equals(RepairParallelism.DATACENTER_AWARE)) { return ((StorageServiceMBean20) ssProxy).forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, repairParallelism.ordinal(), null, null, columnFamilies.toArray(new String[columnFamilies.size()])); }/*from w w w .j av a 2 s . com*/ boolean snapshotRepair = repairParallelism.equals(RepairParallelism.SEQUENTIAL); return ((StorageServiceMBean20) ssProxy).forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, snapshotRepair, false, columnFamilies.toArray(new String[columnFamilies.size()])); }
From source file:org.ejbca.core.ejb.ca.store.CertificateStoreSessionBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRED) @Override/* w ww . j a v a2 s.c o m*/ public CertReqHistory getCertReqHistory(Admin admin, BigInteger certificateSN, String issuerDN) { CertReqHistory retval = null; Collection<CertReqHistoryData> result = CertReqHistoryData.findByIssuerDNSerialNumber(entityManager, issuerDN, certificateSN.toString()); if (result.iterator().hasNext()) { retval = result.iterator().next().getCertReqHistory(); } return retval; }
From source file:com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardConsumerTest.java
/** * Test method for {@link ShardConsumer#consumeShard()} *///from w ww .ja v a 2 s . c o m @Test public final void testConsumeShard() throws Exception { int numRecs = 10; BigInteger startSeqNum = BigInteger.ONE; String streamShardId = "kinesis-0-0"; String testConcurrencyToken = "testToken"; File file = KinesisLocalFileDataCreator.generateTempDataFile(1, "kinesis-0-", numRecs, startSeqNum, "unitTestSCT001"); IKinesisProxy fileBasedProxy = new KinesisLocalFileProxy(file.getAbsolutePath()); final int maxRecords = 2; final int idleTimeMS = 0; // keep unit tests fast ICheckpoint checkpoint = new InMemoryCheckpointImpl(startSeqNum.toString()); checkpoint.setCheckpoint(streamShardId, ExtendedSequenceNumber.TRIM_HORIZON, testConcurrencyToken); when(leaseManager.getLease(anyString())).thenReturn(null); TestStreamlet processor = new TestStreamlet(); StreamConfig streamConfig = new StreamConfig(fileBasedProxy, maxRecords, idleTimeMS, callProcessRecordsForEmptyRecordList, skipCheckpointValidationValue, INITIAL_POSITION_LATEST); ShardInfo shardInfo = new ShardInfo(streamShardId, testConcurrencyToken, null, null); ShardConsumer consumer = new ShardConsumer(shardInfo, streamConfig, checkpoint, processor, leaseManager, parentShardPollIntervalMillis, cleanupLeasesOfCompletedShards, executorService, metricsFactory, taskBackoffTimeMillis, KinesisClientLibConfiguration.DEFAULT_SKIP_SHARD_SYNC_AT_STARTUP_IF_LEASES_EXIST); assertThat(consumer.getCurrentState(), is(equalTo(ConsumerStates.ShardConsumerState.WAITING_ON_PARENT_SHARDS))); consumer.consumeShard(); // check on parent shards Thread.sleep(50L); consumer.consumeShard(); // start initialization assertThat(consumer.getCurrentState(), is(equalTo(ConsumerStates.ShardConsumerState.INITIALIZING))); consumer.consumeShard(); // initialize processor.getInitializeLatch().await(5, TimeUnit.SECONDS); // We expect to process all records in numRecs calls for (int i = 0; i < numRecs;) { boolean newTaskSubmitted = consumer.consumeShard(); if (newTaskSubmitted) { LOG.debug("New processing task was submitted, call # " + i); assertThat(consumer.getCurrentState(), is(equalTo(ConsumerStates.ShardConsumerState.PROCESSING))); // CHECKSTYLE:IGNORE ModifiedControlVariable FOR NEXT 1 LINES i += maxRecords; } Thread.sleep(50L); } assertThat(processor.getShutdownReason(), nullValue()); consumer.notifyShutdownRequested(shutdownNotification); consumer.consumeShard(); assertThat(processor.getNotifyShutdownLatch().await(1, TimeUnit.SECONDS), is(true)); Thread.sleep(50); assertThat(consumer.getShutdownReason(), equalTo(ShutdownReason.REQUESTED)); assertThat(consumer.getCurrentState(), equalTo(ConsumerStates.ShardConsumerState.SHUTDOWN_REQUESTED)); verify(shutdownNotification).shutdownNotificationComplete(); assertThat(processor.isShutdownNotificationCalled(), equalTo(true)); consumer.consumeShard(); Thread.sleep(50); assertThat(consumer.getCurrentState(), equalTo(ConsumerStates.ShardConsumerState.SHUTDOWN_REQUESTED)); consumer.beginShutdown(); Thread.sleep(50L); assertThat(consumer.getShutdownReason(), equalTo(ShutdownReason.ZOMBIE)); assertThat(consumer.getCurrentState(), is(equalTo(ConsumerStates.ShardConsumerState.SHUTTING_DOWN))); consumer.beginShutdown(); consumer.consumeShard(); verify(shutdownNotification, atLeastOnce()).shutdownComplete(); assertThat(consumer.getCurrentState(), is(equalTo(ConsumerStates.ShardConsumerState.SHUTDOWN_COMPLETE))); assertThat(processor.getShutdownReason(), is(equalTo(ShutdownReason.ZOMBIE))); executorService.shutdown(); executorService.awaitTermination(60, TimeUnit.SECONDS); String iterator = fileBasedProxy.getIterator(streamShardId, ShardIteratorType.TRIM_HORIZON.toString()); List<Record> expectedRecords = toUserRecords(fileBasedProxy.get(iterator, numRecs).getRecords()); verifyConsumedRecords(expectedRecords, processor.getProcessedRecords()); file.delete(); }
From source file:info.savestate.saveybot.JSONFileManipulator.java
public String remove(String slotString, String username) { BigInteger slot; try {//from ww w . ja v a 2 s. c om slot = new BigInteger(slotString); } catch (Exception e) { return "uh hhh h-- that's not a number??? lmao bye af"; } JSONArray json = getJSON(); for (int i = 0; i < json.length(); i++) { JSONObject savestate = json.getJSONObject(i); if (savestate.getString("slot").equals(slot.toString())) { if (savestate.getString("name").equals(username)) { json.remove(i); writeJSON(json); return "rip ur msg )));"; } else { return "u can't do that! that savestate belongs to " + savestate.getString("name") + "! O:"; } } } return "savestate not found ! (u should make it!!!)"; }
From source file:de.undercouch.bson4jackson.BsonGenerator.java
@Override public void writeNumber(BigInteger v) throws IOException, JsonGenerationException { int bl = v.bitLength(); if (bl < 32) { writeNumber(v.intValue());/* www. j ava2 s. c o m*/ } else if (bl < 64) { writeNumber(v.longValue()); } else { writeString(v.toString()); } }
From source file:org.apache.chemistry.opencmis.server.impl.atompub.AtomDocumentBase.java
public void writeAlternateLink(String href, String type, String kind, String title, BigInteger length) throws XMLStreamException { XMLStreamWriter xsw = getWriter(); xsw.writeStartElement(Constants.NAMESPACE_ATOM, "link"); xsw.writeAttribute("rel", Constants.REL_ALTERNATE); xsw.writeAttribute("href", href); if (type != null) { xsw.writeAttribute("type", type); }/* w w w .j a va 2 s . co m*/ if (kind != null) { xsw.writeAttribute(Constants.NAMESPACE_RESTATOM, "renditionKind", kind); } if (title != null) { xsw.writeAttribute("title", title); } if (length != null) { xsw.writeAttribute("length", length.toString()); } xsw.writeEndElement(); }
From source file:info.savestate.saveybot.JSONFileManipulator.java
public String whois(String slotString) { BigInteger slot; try {// w w w . jav a 2 s .co m slot = new BigInteger(slotString); } catch (Exception e) { return "idk what the wtf u were doing but " + slotString + " is NOT a number lmao."; } JSONArray json = getJSON(); for (int i = 0; i < json.length(); i++) { JSONObject savestate = json.getJSONObject(i); if (savestate.getString("slot").equals(slot.toString())) return "savestate " + savestate.getString("slot") + " is owned by " + savestate.getString("name") + "!!! ^o^ "; } return "no one owns that savestate!!! (u should change that!)"; }
From source file:com.spotify.reaper.cassandra.JmxProxy.java
public int triggerRepair2dot1(boolean fullRepair, RepairParallelism repairParallelism, String keyspace, Collection<String> columnFamilies, BigInteger beginToken, BigInteger endToken, String cassandraVersion) { if (fullRepair) { // full repair if (repairParallelism.equals(RepairParallelism.DATACENTER_AWARE)) { return ((StorageServiceMBean) ssProxy).forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, repairParallelism.ordinal(), cassandraVersion.startsWith("2.2") ? new HashSet<String>() : null, cassandraVersion.startsWith("2.2") ? new HashSet<String>() : null, fullRepair, columnFamilies.toArray(new String[columnFamilies.size()])); }// w w w .java 2 s .c o m boolean snapshotRepair = repairParallelism.equals(RepairParallelism.SEQUENTIAL); return ((StorageServiceMBean) ssProxy).forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, snapshotRepair ? RepairParallelism.SEQUENTIAL.ordinal() : RepairParallelism.PARALLEL.ordinal(), cassandraVersion.startsWith("2.2") ? new HashSet<String>() : null, cassandraVersion.startsWith("2.2") ? new HashSet<String>() : null, fullRepair, columnFamilies.toArray(new String[columnFamilies.size()])); } // incremental repair return ((StorageServiceMBean) ssProxy).forceRepairAsync(keyspace, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, fullRepair, columnFamilies.toArray(new String[columnFamilies.size()])); }