本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.currentTimeMillis方法的典型用法代码示例。如果您正苦于以下问题:Java U.currentTimeMillis方法的具体用法?Java U.currentTimeMillis怎么用?Java U.currentTimeMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.typedef.internal.U
的用法示例。
在下文中一共展示了U.currentTimeMillis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryFlush
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Flushes every internal buffer if buffer was flushed before passed in
* threshold.
* <p>
* Does not wait for result and does not fail on errors assuming that this method
* should be called periodically.
*/
@Override public void tryFlush() throws IgniteInterruptedException {
if (!busyLock.enterBusy())
return;
try {
for (Buffer buf : bufMappings.values())
buf.flush();
lastFlushTime = U.currentTimeMillis();
}
catch (IgniteInterruptedCheckedException e) {
throw GridCacheUtils.convertToCacheException(e);
}
finally {
leaveBusy();
}
}
示例2: longRunningQueries
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Collect queries that already running more than specified duration.
*
* @param duration Duration to check.
* @return Collection of IDs and statements of long running queries.
*/
public Collection<GridRunningQueryInfo> longRunningQueries(long duration) {
Collection<GridRunningQueryInfo> res = new ArrayList<>();
long curTime = U.currentTimeMillis();
for (ReduceQueryRun run : runs.values()) {
if (run.queryInfo().longQuery(curTime, duration))
res.add(run.queryInfo());
}
for (DistributedUpdateRun upd: updRuns.values()) {
if (upd.queryInfo().longQuery(curTime, duration))
res.add(upd.queryInfo());
}
return res;
}
示例3: awaitEvents
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Waits until total number of events processed is equal or greater then argument passed.
*
* @param cnt Number of events to wait.
* @param timeout Timeout to wait.
* @return {@code True} if successfully waited, {@code false} if timeout happened.
* @throws InterruptedException If thread is interrupted.
*/
public synchronized boolean awaitEvents(int cnt, long timeout) throws InterruptedException {
long start = U.currentTimeMillis();
long now = start;
while (start + timeout > now) {
if (evtCnt >= cnt)
return true;
wait(start + timeout - now);
now = U.currentTimeMillis();
}
return false;
}
示例4: tryToPerformLocalSnapshotOperation
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Try to start local snapshot operation if it is needed by discovery event
*/
private void tryToPerformLocalSnapshotOperation() {
try {
long start = U.currentTimeMillis();
IgniteInternalFuture fut = cctx.snapshot().tryStartLocalSnapshotOperation(firstDiscoEvt);
if (fut != null) {
fut.get();
long end = U.currentTimeMillis();
if (log.isInfoEnabled())
log.info("Snapshot initialization completed [topVer=" + exchangeId().topologyVersion() +
", time=" + (end - start) + "ms]");
}
}
catch (IgniteCheckedException e) {
U.error(log, "Error while starting snapshot operation", e);
}
}
示例5: release
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Shrinks array size if needed.
*/
public void release(byte[] data, int maxMsgSize) {
if (this.data != data)
return;
if (maxMsgSize > this.maxMsgSize)
this.maxMsgSize = maxMsgSize;
this.acquired = false;
long now = U.currentTimeMillis();
if (now - this.lastCheck >= CHECK_FREQ) {
int halfSize = data.length >> 1;
if (this.maxMsgSize < halfSize)
this.data = new byte[halfSize];
this.lastCheck = now;
}
}
示例6: nextPage
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Returns next page for the query.
*
* @param timeout Timeout.
* @param startTime Timeout wait start time.
* @return Next page or {@code null} if no more pages available.
* @throws IgniteCheckedException If fetch failed.
*/
private Collection<R> nextPage(long timeout, long startTime) throws IgniteCheckedException {
Collection<R> res = null;
while (res == null) {
synchronized (this) {
res = queue.poll();
}
if (res == null) {
if (!isDone()) {
loadPage();
long waitTime = timeout == 0 ? Long.MAX_VALUE : timeout - (U.currentTimeMillis() - startTime);
if (waitTime <= 0)
break;
synchronized (this) {
try {
if (queue.isEmpty() && !isDone())
wait(waitTime);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IgniteCheckedException("Query was interrupted: " + qry, e);
}
}
}
else
break;
}
}
checkError();
return res;
}
示例7: Entry
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param type Event type.
* @param path Path.
* @param streamId Stream ID.
* @param bufSize Buffer size.
* @param dataLen Data length.
* @param append Append flag.
* @param overwrite Overwrite flag.
* @param replication Replication.
* @param blockSize Block size.
* @param pos Position.
* @param readLen Read length.
* @param skipCnt Skip count.
* @param readLimit Read limit.
* @param userTime User time.
* @param sysTime System time.
* @param total Read or written bytes.
* @param destPath Destination path.
* @param recursive Recursive flag.
* @param list Listed directories.
*/
Entry(int type, String path, Long streamId, Integer bufSize, Long dataLen, Boolean append,
Boolean overwrite, Integer replication, Long blockSize, Long pos, Integer readLen, Long skipCnt,
Long readLimit, Long userTime, Long sysTime, Long total, String destPath, Boolean recursive,
String[] list) {
threadId = Thread.currentThread().getId();
ts = U.currentTimeMillis();
this.type = type;
this.path = path;
this.streamId = streamId != null ? streamId : -1;
this.bufSize = bufSize != null ? bufSize : -1;
this.dataLen = dataLen != null ? dataLen : -1;
this.append = append;
this.overwrite = overwrite;
this.replication = replication != null ? replication : -1;
this.blockSize = blockSize != null ? blockSize : -1;
this.pos = pos != null ? pos : -1;
this.readLen = readLen != null ? readLen : -1;
this.skipCnt = skipCnt != null ? skipCnt : -1;
this.readLimit = readLimit != null ? readLimit : -1;
this.userTime = userTime != null ? userTime : -1;
this.sysTime = sysTime != null ? sysTime : -1;
this.total = total != null ? total : -1;
this.destPath = destPath;
this.recursive = recursive;
this.list = list;
}
示例8: getExecuteTime
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @return Job execution time.
*/
long getExecuteTime() {
long startTime0 = startTime;
long finishTime0 = finishTime;
return startTime0 == 0 ? 0 : finishTime0 == 0 ?
U.currentTimeMillis() - startTime0 : finishTime0 - startTime0;
}
示例9: checkWalRolloverRequiredDuringInactivityPeriod
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Checks if there was elapsed significant period of inactivity. If WAL auto-archive is enabled using
* {@link #walAutoArchiveAfterInactivity} > 0 this method will activate roll over by timeout.<br>
*/
private void checkWalRolloverRequiredDuringInactivityPeriod() {
if (walAutoArchiveAfterInactivity <= 0)
return; // feature not configured, nothing to do
final long lastRecMs = lastRecordLoggedMs.get();
if (lastRecMs == 0)
return; //no records were logged to current segment, does not consider inactivity
final long elapsedMs = U.currentTimeMillis() - lastRecMs;
if (elapsedMs <= walAutoArchiveAfterInactivity)
return; // not enough time elapsed since last write
if (!lastRecordLoggedMs.compareAndSet(lastRecMs, 0))
return; // record write occurred concurrently
final FileWriteHandle handle = currentHandle();
try {
handle.buf.close();
rollOver(handle);
}
catch (IgniteCheckedException e) {
U.error(log, "Unable to perform segment rollover: " + e.getMessage(), e);
handle.invalidateEnvironment(e);
}
}
示例10: getRate
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @return Total number of hits in last {@link #rateTimeInterval} milliseconds.
*/
public long getRate() {
long curTs = U.currentTimeMillis();
long sum = 0;
for (int i = 0; i < size; i++) {
clearIfObsolete(curTs, i);
sum += untag(taggedCounters.get(i));
}
return sum;
}
示例11: getTotalIdleTime
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @return Total idle time.
*/
long getTotalIdleTime() {
long now = U.currentTimeMillis();
if (totalIdleTime == 0)
return now - createTime;
if (running)
return totalIdleTime;
return totalIdleTime + (now - lastEndTime);
}
示例12: call0
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Implements actual task running.
* @throws IgniteCheckedException On error.
*/
void call0() throws IgniteCheckedException {
execStartTs = U.currentTimeMillis();
Throwable err = null;
HadoopTaskState state = HadoopTaskState.COMPLETED;
HadoopPerformanceCounter perfCntr = null;
try {
perfCntr = HadoopPerformanceCounter.getCounter(ctx.counters(), nodeId);
perfCntr.onTaskSubmit(info, submitTs);
perfCntr.onTaskPrepare(info, execStartTs);
ctx.prepareTaskEnvironment();
runTask(perfCntr);
if (info.type() == MAP && job.info().hasCombiner()) {
// Switch to combiner.
HadoopTaskInfo combineTaskInfo = new HadoopTaskInfo(COMBINE, info.jobId(), info.taskNumber(),
info.attempt(), null);
// Mapper and combiner share the same index.
if (ctx.taskInfo().hasMapperIndex())
combineTaskInfo.mapperIndex(ctx.taskInfo().mapperIndex());
ctx.taskInfo(combineTaskInfo);
try {
runTask(perfCntr);
}
finally {
ctx.taskInfo(info);
}
}
}
catch (HadoopTaskCancelledException ignored) {
state = HadoopTaskState.CANCELED;
}
catch (Throwable e) {
state = HadoopTaskState.FAILED;
err = e;
U.error(log, "Task execution failed.", e);
if (e instanceof Error)
throw e;
}
finally {
execEndTs = U.currentTimeMillis();
if (perfCntr != null)
perfCntr.onTaskFinish(info, execEndTs);
onTaskFinished(new HadoopTaskStatus(state, err, ctx==null ? null : ctx.counters()));
if (combinerInput != null)
combinerInput.close();
if (ctx != null)
ctx.cleanupTaskEnvironment();
}
}
示例13: RemovedItemsCleanupTask
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param timeout Timeout.
*/
RemovedItemsCleanupTask(long timeout) {
this.timeout = timeout;
endTime = U.currentTimeMillis() + timeout;
}
示例14: run
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected VisorEither<VisorQueryResult> run(final VisorScanQueryTaskArg arg) {
try {
IgniteCache<Object, Object> c = ignite.cache(arg.getCacheName());
UUID nid = ignite.localNode().id();
String filterText = arg.getFilter();
long start = U.currentTimeMillis();
IgniteBiPredicate<Object, Object> filter = null;
if (!F.isEmpty(filterText))
filter = new VisorQueryScanRegexFilter(arg.isCaseSensitive(), arg.isRegEx(), filterText);
VisorQueryCursor<Cache.Entry<Object, Object>> cur =
new VisorQueryCursor<>(arg.isNear() ? near(c) : scan(c, arg, filter));
List<Object[]> rows = fetchScanQueryRows(cur, arg.getPageSize());
long duration = U.currentTimeMillis() - start; // Scan duration + fetch duration.
boolean hasNext = cur.hasNext();
// Generate query ID to store query cursor in node local storage.
String qryId = SCAN_QRY_NAME + "-" + UUID.randomUUID();
if (hasNext) {
ignite.cluster().<String, VisorQueryCursor>nodeLocalMap().put(qryId, cur);
scheduleResultSetHolderRemoval(qryId, ignite);
}
else
cur.close();
return new VisorEither<>(new VisorQueryResult(nid, qryId, SCAN_COL_NAMES, rows, hasNext,
duration));
}
catch (Throwable e) {
return new VisorEither<>(new VisorExceptionWrapper(e));
}
}
示例15: doTest
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
private void doTest() throws Exception {
System.gc();
System.gc();
System.gc();
try {
useCache = true;
startGridsMultiThreaded(GRID_CNT);
useCache = false;
Ignite ignite = startGrid();
final IgniteDataStreamer<Integer, String> ldr = ignite.dataStreamer(DEFAULT_CACHE_NAME);
ldr.perNodeBufferSize(8192);
ldr.receiver(DataStreamerCacheUpdaters.<Integer, String>batchedSorted());
ldr.autoFlushFrequency(0);
final LongAdder8 cnt = new LongAdder8();
long start = U.currentTimeMillis();
Thread t = new Thread(new Runnable() {
@SuppressWarnings("BusyWait")
@Override public void run() {
while (true) {
try {
Thread.sleep(10000);
}
catch (InterruptedException ignored) {
break;
}
info(">>> Adds/sec: " + cnt.sumThenReset() / 10);
}
}
});
t.setDaemon(true);
t.start();
int threadNum = 2;//Runtime.getRuntime().availableProcessors();
multithreaded(new Callable<Object>() {
@SuppressWarnings("InfiniteLoopStatement")
@Override public Object call() throws Exception {
ThreadLocalRandom8 rnd = ThreadLocalRandom8.current();
while (true) {
int i = rnd.nextInt(ENTRY_CNT);
ldr.addData(i, vals[rnd.nextInt(vals.length)]);
cnt.increment();
}
}
}, threadNum, "loader");
info("Closing loader...");
ldr.close(false);
long duration = U.currentTimeMillis() - start;
info("Finished performance test. Duration: " + duration + "ms.");
}
finally {
stopAllGrids();
}
}