/** {@inheritDoc} */ @Override public void serialize(IgniteUuid uid, JsonGenerator gen, SerializerProvider ser) throws IOException { gen.writeString(uid.toString()); } };
/** * 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); }
/** * Creates short name of the file in TRASH directory. * The name consists of the whole file path and its unique id. * Upon file cleanup this name will be parsed to extract the path. * Note that in contrast to common practice the composed name contains '/' character. * * @param path The full path of the deleted file. * @param id The file id. * @return The new short name for trash directory. */ static String composeNameForTrash(IgfsPath path, IgniteUuid id) { return id.toString() + TRASH_NAME_SEPARATOR + path.toString(); }
/** * 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()); }
/** * @param duration Duration. */ private Map<String, String> getNearTxs(long duration) { final Collection<GridNearTxLocal> txs = nearTxs(duration); final HashMap<String, String> res = new HashMap<>(txs.size()); for (GridNearTxLocal tx : txs) res.put(tx.xid().toString(), composeTx(tx)); return res; }
/** {@inheritDoc} */ @Override public Serializable execute() { UUID locNodeId = ignite.configuration().getNodeId(); jobCtx.setAttribute("nodeId", locNodeId); jobCtx.setAttribute("jobId", jobCtx.getJobId()); Map<String, String> attrs = new HashMap<>(10); for (int i = 0; i < 10; i++) { String s = jobCtx.getJobId().toString() + i; attrs.put(s, s); } jobCtx.setAttributes(attrs); assert jobCtx.getAttribute("nodeId").equals(locNodeId); assert jobCtx.getAttributes().get("nodeId").equals(locNodeId); assert jobCtx.getAttributes().keySet().containsAll(attrs.keySet()); assert jobCtx.getAttributes().values().containsAll(attrs.values()); return null; } });
/** {@inheritDoc} */ @Override public Object reduce(List<ComputeJobResult> results) { for (ComputeJobResult res : results) { ComputeJobContext jobCtx = res.getJobContext(); assert jobCtx.getAttribute("nodeId").equals(res.getNode().id()); assert jobCtx.getAttributes().get("nodeId").equals(res.getNode().id()); assert jobCtx.getAttribute("jobId").equals(jobCtx.getJobId()); for (int i = 0; i < 10; i++) { String s = jobCtx.getJobId().toString() + i; assert jobCtx.getAttribute(s).equals(s); assert jobCtx.getAttributes().get(s).equals(s); } } return 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; } }
); createNewEntry(newInfo, trashId, newInfo.id().toString());
if (arg.getXid() != null && !locTx.xid().toString().equals(arg.getXid())) continue;
final String name = IgniteUuid.randomUuid().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()); }
/** * 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); }
taskRestRes.setId(tid.toString() + '~' + ctx.localNodeId().toString());
"--xid", toKill[0].getXid().toString(), // Use saved on first run value. "--nodes", grid(0).localNode().consistentId().toString());
putTypedValue("IgniteUuid", ik1.toString(), iv1.toString(), STATUS_SUCCESS); putTypedValue("IgniteUuid", "error", iv1.toString(), STATUS_FAILED); putTypedValue("IgniteUuid", ik1.toString(), "error", STATUS_FAILED); putTypedValue("IgniteUuid", "error", "error", STATUS_FAILED); putTypedValue("org.apache.ignite.lang.IgniteUuid", ik2.toString(), iv2.toString(), STATUS_SUCCESS);
info("Checking session attributes for sibling: " + sibling); checkSessionAttributes(ses, sibling.getJobId().toString(), type);
final String name = IgniteUuid.randomUuid().toString();
/** * @param duration Duration. */ private Map<String, String> getNearTxs(long duration) { final Collection<GridNearTxLocal> txs = nearTxs(duration); final HashMap<String, String> res = new HashMap<>(txs.size()); for (GridNearTxLocal tx : txs) res.put(tx.xid().toString(), composeTx(tx)); return res; }