List of usage examples for java.lang System identityHashCode
@HotSpotIntrinsicCandidate public static native int identityHashCode(Object x);
From source file:org.apache.mnemonic.ChunkBufferNGTest.java
@Test(dependsOnMethods = { "testGenChunkBuffers" }) public void testCheckChunkBuffers() { Checksum cs = new CRC32(); cs.reset();//from w w w.j a va 2s . c o m NonVolatileMemAllocator act = new NonVolatileMemAllocator( Utils.getNonVolatileMemoryAllocatorService("pmalloc"), 1L, "./pmchunkbuffertest.dat", false); act.setChunkReclaimer(new Reclaim<Long>() { @Override public boolean reclaim(Long mres, Long sz) { System.out.println(String.format("Reclaim Memory Chunk: %X Size: %s", System.identityHashCode(mres), null == sz ? "NULL" : sz.toString())); return false; } }); DurableChunk<NonVolatileMemAllocator> mch; mch = act.retrieveChunk(act.getHandler(m_keyid)); Assert.assertNotNull(mch); long bufcnt = mch.getSize() / m_bufsize; ChunkBuffer ckbuf; byte[] buf; for (long idx = 0; idx < bufcnt; ++idx) { ckbuf = mch.getChunkBuffer(idx * m_bufsize, m_bufsize); Assert.assertNotNull(ckbuf); buf = new byte[m_bufsize]; ckbuf.get().clear(); ckbuf.get().get(buf); cs.update(buf, 0, buf.length); } act.close(); Assert.assertEquals(m_checksum, cs.getValue()); Assert.assertEquals(m_count, bufcnt); System.out.println( String.format("The checksum of chunk buffers are %d, Total count is %d", m_checksum, m_count)); }
From source file:chronos.mbeans.QuartzSchedulerAdapter.java
/** * {@inheritDoc}/*w w w.jav a 2s . c om*/ * * @see chronos.mbeans.QuartzSchedulerAdapterMBean#start() */ @Override public final void start() { if (schedulerRef.get() == null) { final StdSchedulerFactory factory = new StdSchedulerFactory(); try { final boolean createOwnScheduler = factory.getAllSchedulers().size() == 0; if (createOwnScheduler) { createOwnScheduler(factory); } else { logger.debug("Using existing scheduler instance"); } final Scheduler scheduler = factory.getScheduler(); if (null != scheduler) { logger.trace("Got scheduler " + getUniqueIdentifier(scheduler.getSchedulerName(), scheduler.getSchedulerInstanceId()) + "@" + System.identityHashCode(scheduler)); TestJob.initializeTestJob(scheduler); if (schedulerRef.compareAndSet(null, scheduler)) { if (createOwnScheduler) { logger.debug("Quartz scheduler successfully created. Starting..."); try { scheduler.start(); logger.debug("Quartz started up successfully"); } catch (final SchedulerException e) { logger.error("Scheduler start() failed!: " + e.getMessage(), e); } } } else { logger.warn("Tried to set schedulerRef, expecting null but was already set!"); } } else { logger.error("factory.getScheduler() returned null!"); } } catch (final SchedulerException e) { logger.error("Initializing scheduler failed!: " + e.getMessage(), e); } } }
From source file:org.dataconservancy.dcs.util.PooledKeyDigestPathAlgorithm.java
/** * Calculate a hash code over the supplied string. * * @param in the string// w w w . j ava 2 s. c om * @return the hash code, encoded in hexadecimal. */ String hash(String in) { MessageDigest md = null; try { md = mdPool.borrowObject(); return new String(Hex.encodeHex(md.digest(in.getBytes("UTF-8")))); } catch (Exception e) { throw new RuntimeException("Could not calculate id hash", e); } finally { // There's no guarantees by the JVM when the finalizer will run, so that is why we allow the pool // to grow if it is exhausted. if (md != null) { try { mdPool.returnObject(md); } catch (Exception e) { log.warn("Error returning MessageDigest object (0x{}) to the pool: {}", new Object[] { Integer.toHexString(System.identityHashCode(md)), e.getMessage() }, e); } } } }
From source file:org.diffkit.diff.custom.DKCustomDBSink.java
public String toString() { if (DKRuntime.getInstance().getIsTest()) return _summaryFile.getName(); return String.format("%s@%x[%s]", ClassUtils.getShortClassName(this.getClass()), System.identityHashCode(this), _summaryFile.getPath()); }
From source file:org.codehaus.groovy.grails.commons.metaclass.WeakGenericDynamicProperty.java
public Object get(Object object) { String propertyKey = System.identityHashCode(object) + getPropertyName(); SoftReference<Object> ref = propertyToInstanceMap.get(propertyKey); Object val = (ref != null) ? ref.get() : null; if (val != null) { return val; } else if (this.initialValueGenerator != null) { final Object value = this.initialValueGenerator.execute(object); propertyToInstanceMap.put(propertyKey, new SoftReference<Object>(value)); return value; } else if (this.initialValue != null) { propertyToInstanceMap.put(propertyKey, new SoftReference<Object>(this.initialValue)); return this.initialValue; }// www . j ava2 s .c om return null; }
From source file:it.unibo.alchemist.boundary.monitors.EnvironmentInspector.java
@Override public void stepDone(final Environment<T> env, final Reaction<T> r, final Time time, final long step) { mutex.acquireUninterruptibly();/*from w w w .ja v a2 s.c o m*/ if (System.identityHashCode(fpCache) != System.identityHashCode(filePath)) { fpCache = filePath; if (writer != null) { writer.close(); } try { writer = new PrintStream(new File(fpCache), StandardCharsets.UTF_8.name()); } catch (FileNotFoundException | UnsupportedEncodingException e) { L.error("Could create a PrintStream", e); } } final double sample = interval.getVal() * FastMath.pow(10, intervaloom.getVal()); final boolean log = mode.equals(Mode.TIME) ? time.toDouble() - lastUpdate >= sample : step - lastStep >= sample; if (log) { lastUpdate = time.toDouble(); lastStep = step; writeData(env, r, time, step); } mutex.release(); }
From source file:gdsc.smlm.model.ImageModel.java
/** * Construct a new image model/*from w ww . ja va 2s . co m*/ * * @param tOn * Average on-state time * @param tOff * Average off-state time for the first dark state * @param tOff2 * Average off-state time for the second dark state * @param nBlinks * Average number of blinks int the first dark state (used for each burst between second dark states) * @param nBlinks2 * Average number of blinks into the second dark state */ public ImageModel(double tOn, double tOff, double tOff2, double nBlinks, double nBlinks2) { init(tOn, tOff, tOff2, nBlinks, nBlinks2, new Well19937c(System.currentTimeMillis() + System.identityHashCode(this))); }
From source file:org.n52.iceland.config.json.JsonConfiguration.java
/** * Destroys this configuration by executing any pending write. * * @see Debouncer#finish()//from www . j a va 2 s . c o m */ @Override public void destroy() { LOG.info("Destroying {}", System.identityHashCode(this)); this.debouncer.finish(); }
From source file:org.apache.mnemonic.DurablePersonNGTest.java
@Test(expectedExceptions = { OutOfHybridMemory.class }) public void testGenPeople() throws OutOfHybridMemory, RetrieveDurableEntityError { Random rand = Utils.createRandom(); NonVolatileMemAllocator act = new NonVolatileMemAllocator( Utils.getNonVolatileMemoryAllocatorService("pmalloc"), 1024L * 1024 * 1024, "./pobj_person.dat", true);/* w w w .ja v a 2 s .co m*/ cKEYCAPACITY = act.handlerCapacity(); act.setBufferReclaimer(new Reclaim<ByteBuffer>() { @Override public boolean reclaim(ByteBuffer mres, Long sz) { System.out.println(String.format("Reclaim Memory Buffer: %X Size: %s", System.identityHashCode(mres), null == sz ? "NULL" : sz.toString())); return false; } }); act.setChunkReclaimer(new Reclaim<Long>() { @Override public boolean reclaim(Long mres, Long sz) { System.out.println(String.format("Reclaim Memory Chunk: %X Size: %s", System.identityHashCode(mres), null == sz ? "NULL" : sz.toString())); return false; } }); for (long i = 0; i < cKEYCAPACITY; ++i) { act.setHandler(i, 0L); } Person<Integer> mother; Person<Integer> person; Checksum pic_cs = new CRC32(); pic_cs.reset(); Checksum fp_cs = new CRC32(); fp_cs.reset(); long keyidx = 0; long val; try { while (true) { // if (keyidx >= KEYCAPACITY) break; keyidx %= cKEYCAPACITY; System.out.printf("************ Generating People on Key %d ***********\n", keyidx); val = act.getHandler(keyidx); if (0L != val) { PersonFactory.restore(act, val, true); } person = PersonFactory.create(act); person.setAge((short) rand.nextInt(50)); person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true); person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true); person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true); person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true); person.setPicture(genuptBuffer(act, pic_cs, genRandSize()), true); person.setPreference(genuptChunk(act, fp_cs, genRandSize()), true); act.setHandler(keyidx, person.getHandler()); pic_checksum = pic_cs.getValue(); fp_checksum = fp_cs.getValue(); for (int deep = 0; deep < rand.nextInt(100); ++deep) { mother = PersonFactory.create(act); mother.setAge((short) (50 + rand.nextInt(50))); mother.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true); mother.setPicture(genuptBuffer(act, pic_cs, genRandSize()), true); mother.setPreference(genuptChunk(act, fp_cs, genRandSize()), true); person.setMother(mother, true); pic_checksum = pic_cs.getValue(); fp_checksum = fp_cs.getValue(); person = mother; } ++keyidx; } } finally { act.close(); } }
From source file:com.jaspersoft.jasperserver.api.engine.jasperreports.util.JarURLStreamHandler.java
protected int hashCode(URL u) { return System.identityHashCode(u); }