/** * Opens file in the browser with given HTML content. * * @param html HTML content. * @throws IOException Thrown in case of any errors. */ private static void openHtmlFile(String html) throws IOException { File temp = File.createTempFile(IgniteUuid.randomUuid().toString(), ".html"); BufferedWriter bw = new BufferedWriter(new FileWriter(temp)); bw.write(html); bw.close(); Desktop.getDesktop().browse(temp.toURI()); }
/** * Constructor. * * @param creatorNodeId Creator node ID. */ protected TcpDiscoveryAbstractMessage(UUID creatorNodeId) { id = IgniteUuid.fromUuid(creatorNodeId); }
/** {@inheritDoc} */ @Override public int hashCode() { int res = queueId.hashCode(); res = 31 * res + (int)(idx ^ (idx >>> 32)); return res; }
/** * Constructs unique affinity UUID based on affinity key. * * @param affKey Affinity key to use for collocation. */ public AffinityUuid(Object affKey) { super(IgniteUuid.randomUuid(), affKey); }
/** * JUnit. */ @Test public void testGridUuid() { IgniteUuid id1 = IgniteUuid.randomUuid(); IgniteUuid id2 = IgniteUuid.randomUuid(); assert id1.compareTo(id2) == -1; assert id2.compareTo(id1) == 1; assert id1.compareTo(id1) == 0; assert id2.compareTo(id2) == 0; assert id1.hashCode() != id2.hashCode(); assert !id1.equals(id2); assert id1.iterator().hasNext(); assert id1.iterator().next().equals(id1); assert id2.iterator().hasNext(); assert id2.iterator().next().equals(id2); }
/** * JUnit. */ @Test public void testToString() { IgniteUuid id1 = IgniteUuid.randomUuid(); String id8_1 = U.id8(id1); info("ID1: " + id1); info("ID8_1: " + id8_1); String s = id1.toString(); IgniteUuid id2 = IgniteUuid.fromString(s); String id8_2 = U.id8(id2); info("ID2: " + id2); info("ID8_2: " + id8_2); assertNotNull(id2); assertNotNull(id8_1); assertNotNull(id8_2); assertEquals(8, id8_1.length()); assertEquals(8, id8_2.length()); assertEquals(id1, id2); assertEquals(id8_1, id8_2); }
/** {@inheritDoc} */ @Override public void serialize(IgniteUuid uid, JsonGenerator gen, SerializerProvider ser) throws IOException { gen.writeString(uid.toString()); } };
/** * @throws Exception If failed. */ @Test public void testUUID() throws Exception { UUID uuid = UUID.randomUUID(); jcache().put("uuidKey", uuid); String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_GET, "key", "uuidKey"); info("Get command result: " + ret); assertCacheOperation(ret, uuid.toString()); IgniteUuid igniteUuid = IgniteUuid.fromUuid(uuid); jcache().put("igniteUuidKey", igniteUuid); ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_GET, "key", "igniteUuidKey"); info("Get command result: " + ret); assertCacheOperation(ret, igniteUuid.toString()); }
taskRestRes.setId(tid.toString() + '~' + ctx.localNodeId().toString()); IgniteUuid tid = !F.isEmpty(tidParam) ? IgniteUuid.fromString(tidParam) : null;
/** {@inheritDoc} */ @Override public Serializable execute() { WaitAttributeType m = argument(0); checkSessionAttributes(taskSes, "fut", m); IgniteUuid jobId = jobCtx.getJobId(); for (int i = 0; i < ATTR_NUM; i ++) { String key = createKey(jobId.toString(), m, i); String val = createValue(jobId.toString(), m, i); taskSes.setAttribute(key, val); } // Check that attributes just set are present. checkSessionAttributes(taskSes, jobId.toString(), m); Collection<ComputeJobSibling> siblings = taskSes.getJobSiblings(); if (log.isInfoEnabled()) log.info("Got siblings from job [size=" + siblings.size() + ", siblings=" + siblings + ']'); // Check attributes from siblings. for (ComputeJobSibling sibling : taskSes.getJobSiblings()) { if (!sibling.getJobId().equals(jobId)) checkSessionAttributes(taskSes, sibling.getJobId().toString(), m); } try { taskSes.waitForAttribute("done", true, 0); } catch (InterruptedException e) { throw new IgniteException("Got interrupted while waiting for 'done' attribute.", e); } return null; } }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { return o == this || o instanceof GridDeploymentInfoBean && clsLdrId.equals(((GridDeploymentInfoBean)o).clsLdrId); }
/** * Creates new pseudo-random ID. * * @return Newly created pseudo-random ID. */ public static IgniteUuid randomUuid() { return new IgniteUuid(VM_ID, cntGen.incrementAndGet()); }
/** {@inheritDoc} */ @Override public void connect() throws IOException { URL url = getURL(); // Gets class loader UUID. IgniteUuid ldrId = IgniteUuid.fromString(url.getHost()); // Gets resource name. String name = url.getPath(); GridDeployment dep = mgr.getDeployment(ldrId); if (dep != null) { in = dep.classLoader().getParent().getResourceAsStream(name); // If resource exists connected = true; } }
@Override public int compare(IgniteUuid u1, IgniteUuid u2) { if (u1 == u2) return 0; if (u1 == null) return -1; return u1.compareTo(u2); } };
/** * @param timeout Timeout for this object. */ protected GridTimeoutObjectAdapter(long timeout) { this(IgniteUuid.randomUuid(), timeout); }
/** * Gets 8-character substring of {@link org.apache.ignite.lang.IgniteUuid} (for terse logging). * The ID8 will be constructed as follows: * <ul> * <li>Take first 4 digits for global ID, i.e. {@code GridUuid.globalId()}.</li> * <li>Take last 4 digits for local ID, i.e. {@code GridUuid.localId()}.</li> * </ul> * * @param id Input ID. * @return 8-character representation of {@code GridUuid}. */ public static String id8(IgniteUuid id) { String s = id.toString(); return s.substring(0, 4) + s.substring(s.length() - 4); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) return true; else if (obj instanceof TcpDiscoveryAbstractMessage) return id.equals(((TcpDiscoveryAbstractMessage)obj).id); return false; }
/** * @return Version represented as {@code GridUuid} */ public IgniteUuid asGridUuid() { return new IgniteUuid(new UUID(topVer, nodeOrderDrId), order); }
return IgniteUuid.fromString(val);
/** {@inheritDoc} */ @Override public int compareTo(@NotNull IgfsBlockKey o) { int res = fileId.compareTo(o.fileId); if (res != 0) return res; long v1 = blockId; long v2 = o.blockId; if (v1 != v2) return v1 > v2 ? 1 : -1; if (affKey == null && o.affKey == null) return 0; if (affKey != null && o.affKey != null) return affKey.compareTo(o.affKey); return affKey != null ? -1 : 1; }