List of usage examples for java.lang Long toHexString
public static String toHexString(long i)
From source file:org.lilyproject.hadooptestfw.fork.HBaseTestingUtility.java
/** * Expire a ZooKeeper session as recommended in ZooKeeper documentation * http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A4 * There are issues when doing this://from w w w .j a va 2s . c o m * [1] http://www.mail-archive.com/dev@zookeeper.apache.org/msg01942.html * [2] https://issues.apache.org/jira/browse/ZOOKEEPER-1105 * * @param nodeZK - the ZK to make expiry * @param checkStatus - true to check if the we can create a HTable with the * current configuration. */ public void expireSession(ZooKeeperWatcher nodeZK, boolean checkStatus) throws Exception { Configuration c = new Configuration(this.conf); String quorumServers = ZKConfig.getZKQuorumServersString(c); int sessionTimeout = 500; ZooKeeper zk = nodeZK.getRecoverableZooKeeper().getZooKeeper(); byte[] password = zk.getSessionPasswd(); long sessionID = zk.getSessionId(); // Expiry seems to be asynchronous (see comment from P. Hunt in [1]), // so we create a first watcher to be sure that the // event was sent. We expect that if our watcher receives the event // other watchers on the same machine will get is as well. // When we ask to close the connection, ZK does not close it before // we receive all the events, so don't have to capture the event, just // closing the connection should be enough. ZooKeeper monitor = new ZooKeeper(quorumServers, 1000, new org.apache.zookeeper.Watcher() { @Override public void process(WatchedEvent watchedEvent) { LOG.info("Monitor ZKW received event=" + watchedEvent); } }, sessionID, password); // Making it expire ZooKeeper newZK = new ZooKeeper(quorumServers, sessionTimeout, EmptyWatcher.instance, sessionID, password); newZK.close(); LOG.info("ZK Closed Session 0x" + Long.toHexString(sessionID)); // Now closing & waiting to be sure that the clients get it. monitor.close(); if (checkStatus) { new HTable(new Configuration(conf), HConstants.META_TABLE_NAME).close(); } }
From source file:org.sakaiproject.bbb.tool.entity.BBBMeetingEntityProvider.java
/** Generate a random password */ private String generatePassword() { Random randomGenerator = new Random(System.currentTimeMillis()); return Long.toHexString(randomGenerator.nextLong()); }
From source file:com.trsst.server.TrsstAdapter.java
/** * Adds entries to the specified feed for the specified search and paging * parameters. Importantly, this method MUST call addPagingLinks before * adding entries in order to generate valid atom xml. * //w ww . j a va 2 s. c o m * @return the total number of entries matching the query. */ protected int addEntriesFromStorage(Feed feed, int start, int length, Date after, Date before, String query, String[] mentions, String[] tags, String verb) { long[] entryIds = persistence.getEntryIdsForFeedId(feedId, 0, length, after, before, query, mentions, tags, verb); int end = Math.min(entryIds.length, start + length); Document<Entry> document; for (int i = start; i < end; i++) { document = getEntry(persistence, feedId, entryIds[i]); if (document != null) { feed.addEntry((Entry) document.getRoot().clone()); } else { log.error("Could not find entry for id: " + feedId + " : " + Long.toHexString(entryIds[i])); } } return entryIds.length; }
From source file:org.apache.geode.internal.cache.Oplog.java
/** * Return bytes read./*from ww w . j a v a 2s. com*/ */ long recoverDrf(OplogEntryIdSet deletedIds, boolean alreadyRecoveredOnce, boolean latestOplog) { File drfFile = this.drf.f; if (drfFile == null) { this.haveRecoveredDrf = true; return 0L; } lockCompactor(); try { if (this.haveRecoveredDrf && !getHasDeletes()) return 0L; // do this while holding lock if (!this.haveRecoveredDrf) { this.haveRecoveredDrf = true; } logger.info(LocalizedMessage.create(LocalizedStrings.DiskRegion_RECOVERING_OPLOG_0_1_2, new Object[] { toString(), drfFile.getAbsolutePath(), getParent().getName() })); this.recoverDelEntryId = DiskStoreImpl.INVALID_ID; boolean readLastRecord = true; CountingDataInputStream dis = null; try { int recordCount = 0; boolean foundDiskStoreRecord = false; FileInputStream fis = null; try { fis = new FileInputStream(drfFile); dis = new CountingDataInputStream(new BufferedInputStream(fis, 32 * 1024), drfFile.length()); boolean endOfLog = false; while (!endOfLog) { if (dis.atEndOfFile()) { endOfLog = true; break; } readLastRecord = false; byte opCode = dis.readByte(); if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) { logger.trace(LogMarker.PERSIST_RECOVERY, "drf byte={} location={}", opCode, Long.toHexString(dis.getCount())); } switch (opCode) { case OPLOG_EOF_ID: // we are at the end of the oplog. So we need to back up one byte dis.decrementCount(); endOfLog = true; break; case OPLOG_DEL_ENTRY_1ID: case OPLOG_DEL_ENTRY_2ID: case OPLOG_DEL_ENTRY_3ID: case OPLOG_DEL_ENTRY_4ID: case OPLOG_DEL_ENTRY_5ID: case OPLOG_DEL_ENTRY_6ID: case OPLOG_DEL_ENTRY_7ID: case OPLOG_DEL_ENTRY_8ID: readDelEntry(dis, opCode, deletedIds, parent); recordCount++; break; case OPLOG_DISK_STORE_ID: readDiskStoreRecord(dis, this.drf.f); foundDiskStoreRecord = true; recordCount++; break; case OPLOG_MAGIC_SEQ_ID: readOplogMagicSeqRecord(dis, this.drf.f, OPLOG_TYPE.DRF); break; case OPLOG_GEMFIRE_VERSION: readGemfireVersionRecord(dis, this.drf.f); recordCount++; break; case OPLOG_RVV: long idx = dis.getCount(); readRVVRecord(dis, this.drf.f, true, latestOplog); recordCount++; break; default: throw new DiskAccessException( LocalizedStrings.Oplog_UNKNOWN_OPCODE_0_FOUND_IN_DISK_OPERATION_LOG .toLocalizedString(opCode), getParent()); } readLastRecord = true; // @todo // if (rgn.isDestroyed()) { // break; // } } // while } finally { if (dis != null) { dis.close(); } if (fis != null) { fis.close(); } } if (!foundDiskStoreRecord && recordCount > 0) { throw new DiskAccessException( "The oplog file \"" + this.drf.f + "\" does not belong to the init file \"" + getParent().getInitFile() + "\". Drf did not contain a disk store id.", getParent()); } } catch (EOFException ignore) { // ignore since a partial record write can be caused by a crash } catch (IOException ex) { getParent().getCancelCriterion().checkCancelInProgress(ex); throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_READING_FILE_DURING_RECOVERY_FROM_0 .toLocalizedString(drfFile.getPath()), ex, getParent()); } catch (CancelException e) { if (logger.isDebugEnabled()) { logger.debug("Oplog::readOplog:Error in recovery as Cache was closed", e); } } catch (RegionDestroyedException e) { if (logger.isDebugEnabled()) { logger.debug("Oplog::readOplog:Error in recovery as Region was destroyed", e); } } catch (IllegalStateException e) { throw e; } // Add the Oplog size to the Directory Holder which owns this oplog, // so that available space is correctly calculated & stats updated. long byteCount = 0; if (!readLastRecord) { // this means that there was a crash // and hence we should not continue to read // the next oplog this.crashed = true; if (dis != null) { byteCount = dis.getFileLength(); } } else { if (dis != null) { byteCount = dis.getCount(); } } if (!alreadyRecoveredOnce) { setRecoveredDrfSize(byteCount); this.dirHolder.incrementTotalOplogSize(byteCount); } return byteCount; } finally { unlockCompactor(); } }
From source file:com.android.mms.ui.ComposeMessageActivity.java
/** * Copies media from an Mms to the DrmProvider * @param msgId//from ww w. j a v a 2 s .co m */ private boolean saveRingtone(long msgId) { boolean result = true; PduBody body = null; try { body = SlideshowModel.getPduBody(this, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId)); } catch (MmsException e) { Log.e(TAG, "copyToDrmProvider can't load pdu body: " + msgId); } if (body == null) { return false; } int partNum = body.getPartsNum(); for (int i = 0; i < partNum; i++) { PduPart part = body.getPart(i); String type = new String(part.getContentType()); if (DrmUtils.isDrmType(type)) { // All parts (but there's probably only a single one) have to be successful // for a valid result. result &= copyPart(part, Long.toHexString(msgId)); } } return result; }
From source file:com.peterbochs.instrument.InstrumentPanel.java
private void addProfileMemoryFromComboBox(Long l) { for (int x = 0; x < jProfilingFromComboBox.getItemCount(); x++) { if (jProfilingFromComboBox.getItemAt(x).toString().trim().equals(l.toString().trim())) { return; }/*w ww . java 2 s .c o m*/ } jProfilingFromComboBox.addItem("0x" + Long.toHexString(l)); }
From source file:com.peterbochs.instrument.InstrumentPanel.java
private void addProfileMemoryToComboBox(Long l) { for (int x = 0; x < jProfilingToComboBox.getItemCount(); x++) { if (jProfilingToComboBox.getItemAt(x).toString().trim().equals(l.toString().trim())) { return; }//from ww w . jav a 2s . co m } jProfilingToComboBox.addItem("0x" + Long.toHexString(l)); }
From source file:org.apache.bookkeeper.bookie.BookieShell.java
/** * Scan over an entry log file.//w ww .ja v a 2 s . c om * * @param logId * Entry Log File id. * @param printMsg * Whether printing the entry data. */ protected void scanEntryLog(long logId, final boolean printMsg) throws Exception { System.out.println("Scan entry log " + logId + " (" + Long.toHexString(logId) + ".log)"); scanEntryLog(logId, new EntryLogScanner() { @Override public boolean accept(long ledgerId) { return true; } @Override public void process(long ledgerId, long startPos, ByteBuffer entry) { formatEntry(startPos, entry, printMsg); } }); }
From source file:com.android.mms.ui.ComposeMessageActivity.java
/** * Copies media from an Mms to the "download" directory on the SD card. If any of the parts * are audio types, drm'd or not, they're copied to the "Ringtones" directory. * @param msgId/* w ww . j a v a 2s.c om*/ */ private boolean copyMedia(long msgId) { boolean result = true; PduBody body = null; try { body = SlideshowModel.getPduBody(this, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId)); } catch (MmsException e) { Log.e(TAG, "copyMedia can't load pdu body: " + msgId); } if (body == null) { return false; } int partNum = body.getPartsNum(); for (int i = 0; i < partNum; i++) { PduPart part = body.getPart(i); // all parts have to be successful for a valid result. result &= copyPart(part, Long.toHexString(msgId)); } return result; }
From source file:org.apache.bookkeeper.bookie.BookieShell.java
/** * Scan over an entry log file for a particular entry * /*from w w w.ja v a 2s . com*/ * @param logId * Entry Log File id. * @param ledgerId * id of the ledger * @param entryId * entryId of the ledger we are looking for (-1 for all of the entries of the ledger) * @param printMsg * Whether printing the entry data. * @throws Exception */ protected void scanEntryLogForSpecificEntry(long logId, final long lId, final long eId, final boolean printMsg) throws Exception { System.out.println("Scan entry log " + logId + " (" + Long.toHexString(logId) + ".log)" + " for LedgerId " + lId + ((eId == -1) ? "" : " for EntryId " + eId)); final MutableBoolean entryFound = new MutableBoolean(false); scanEntryLog(logId, new EntryLogScanner() { @Override public boolean accept(long ledgerId) { return ((lId == ledgerId) && ((!entryFound.booleanValue()) || (eId == -1))); } @Override public void process(long ledgerId, long startPos, ByteBuffer entry) { long entrysLedgerId = entry.getLong(); long entrysEntryId = entry.getLong(); entry.rewind(); if ((ledgerId == entrysLedgerId) && (ledgerId == lId) && ((entrysEntryId == eId)) || (eId == -1)) { entryFound.setValue(true); formatEntry(startPos, entry, printMsg); } } }); if (!entryFound.booleanValue()) { System.out.println("LedgerId " + lId + ((eId == -1) ? "" : " EntryId " + eId) + " is not available in the entry log " + logId + " (" + Long.toHexString(logId) + ".log)"); } }