APISonar


org.rapidoid.u.U.time

> org > rapidoid > u > U > time
org APIs rapidoid APIs u APIs U APIs time APIs

Example 1
public TUUID() {
		UUID uuid = UUID.randomUUID();
		this.time = U.time();
		this.uuidHigh = uuid.getMostSignificantBits();
		this.uuidLow = uuid.getLeastSignificantBits();
	}
Example 2
public static void endMeasure(String info) {
		long delta = U.time() - state.measureStart;
		Log.info("Benchmark", "info", info, "time", delta + " ms");
	}
Example 3
public static TokenAuthData getAuth(Map<String, ? extends Serializable> token) {
		TokenAuthData data = new TokenAuthData();

		data.user = (String) token.get(_USER);
		data.scope = scope((String) token.get(_SCOPE));
		data.expires = (Long) token.get(_EXPIRES);

		if (data.expires == null || data.expires > U.time()) {
			return data;
		} else {
			return null; // expired
		}
	}
Example 4
public static void doBenchmark(String name, int count, BenchmarkOperation operation, boolean silent) {
		long start = U.time();

		for (int i = 0; i < count; i++) {
			operation.run(i);
		}

		if (!silent) {
			benchmarkComplete(name, count, start);
		}
	}
Example 5
private V setValueInsideWriteLock(V newValue) {
		CachedValue<V> cached = cachedValue; // read the cached value
		V oldValue = cached != null ? cached.value : null;

		if (newValue != null) {
			long expiresAt = ttlInMs > 0 ? U.time() + ttlInMs : Long.MAX_VALUE;
			cachedValue = new CachedValue<>(newValue, expiresAt);

		} else {
			cachedValue = null;
		}

		return oldValue;
	}
Example 6
private void retryConnecting(ConnectionTarget target) throws IOException {
		Log.warn("Reconnecting...", "address", target.addr);
		target.socketChannel = SocketChannel.open();
		target.retryAfter = U.time() + 1000;
		connect(target);
	}
Example 7
public static TimeSeries measure(String title, final Callable<? extends Number> var, long period, TimeUnit timeUnit) {

		final TimeSeries ts = new TimeSeries();
		ts.title(title);

		Jobs.every(period, timeUnit).run(() -> {
			Number value = Lmbd.call(var);
			if (value != null) ts.put(U.time(), value.doubleValue());
		});

		register("/" + Str.textToId(title), ts);

		return ts;
	}
Example 8
public Object execute(final Req req, final Resp resp) {

		ProxyMapping mapping = findMapping(req);
		if (mapping == null) return null; // not found!

		req.async();

		process(req, resp, mapping, 1, U.time());

		return req;
	}
Example 9
public ConnectionTarget(SocketChannel socketChannel, InetSocketAddress addr, Protocol protocol,
	                        ChannelHolderImpl holder, boolean reconnecting, ConnState state) {

		U.notNull(protocol, "connection protocol");
		U.notNull(holder, "connection holder");

		this.socketChannel = socketChannel;
		this.addr = addr;
		this.protocol = protocol;
		this.retryAfter = U.time();
		this.holder = holder;
		this.reconnecting = reconnecting;
		this.state = state;
	}
Example 10
public void authorize(UserInfo user) {
		Ctxs.required().setUser(user);

		req.token().put(Tokens._USER, user.username);

		long ttl = Conf.TOKEN.entry("ttl").or(0);
		long expiresOn = ttl > 0 ? U.time() + ttl : Long.MAX_VALUE;
		req.token().put(Tokens._EXPIRES, expiresOn);

		req.tokenChanged.set(true);
	}