try { do { shmId = ShmId.createRandom(); } while (segments.containsKey(shmId)); fis = shmFactory.createDescriptor(clientName, SHM_LENGTH);
/** * Generate a random ShmId. * * We generate ShmIds randomly to prevent a malicious client from * successfully guessing one and using that to interfere with another * client. */ public static ShmId createRandom() { return new ShmId(random.nextLong(), random.nextLong()); }
raf.setLength(8192); FileInputStream shmStream = new FileInputStream(raf.getFD()); shm = new ShortCircuitShm(ShmId.createRandom(), shmStream); ShortCircuitReplica replica = new ShortCircuitReplica(key, dataIn, metaIn, shortCircuitCache,
try { do { shmId = ShmId.createRandom(); } while (segments.containsKey(shmId)); fis = shmFactory.createDescriptor(clientName, SHM_LENGTH);
FileInputStream stream = factory.createDescriptor("testAllocateSlots", 4096); ShortCircuitShm shm = new ShortCircuitShm(ShmId.createRandom(), stream); int numSlots = 0; ArrayList<Slot> slots = new ArrayList<Slot>();
FileInputStream stream = factory.createDescriptor("testAllocateSlots", 4096); ShortCircuitShm shm = new ShortCircuitShm(ShmId.createRandom(), stream); int numSlots = 0; ArrayList<Slot> slots = new ArrayList<Slot>();
try { do { shmId = ShmId.createRandom(); } while (segments.containsKey(shmId)); fis = shmFactory.createDescriptor(clientName, SHM_LENGTH);
public static ShmId convert(ShortCircuitShmIdProto shmId) { return new ShmId(shmId.getHi(), shmId.getLo()); }
@Test(timeout=60000) public void testStartupShutdown() throws Exception { File path = new File(TEST_BASE, "testStartupShutdown"); path.mkdirs(); SharedFileDescriptorFactory factory = SharedFileDescriptorFactory.create("shm_", new String[] { path.getAbsolutePath() } ); FileInputStream stream = factory.createDescriptor("testStartupShutdown", 4096); ShortCircuitShm shm = new ShortCircuitShm(ShmId.createRandom(), stream); shm.free(); stream.close(); FileUtil.fullyDelete(path); }
@Test(timeout=60000) public void testStartupShutdown() throws Exception { File path = new File(TEST_BASE, "testStartupShutdown"); path.mkdirs(); SharedFileDescriptorFactory factory = SharedFileDescriptorFactory.create("shm_", new String[] { path.getAbsolutePath() } ); FileInputStream stream = factory.createDescriptor("testStartupShutdown", 4096); ShortCircuitShm shm = new ShortCircuitShm(ShmId.createRandom(), stream); shm.free(); stream.close(); FileUtil.fullyDelete(path); }
public static ShmId convert(ShortCircuitShmIdProto shmId) { return new ShmId(shmId.getHi(), shmId.getLo()); }
public static ShmId convert(ShortCircuitShmIdProto shmId) { return new ShmId(shmId.getHi(), shmId.getLo()); }
@Override public String toString() { return String.format("SlotId(%s:%d)", shmId.toString(), slotIdx); } }
@Override public String toString() { return String.format("SlotId(%s:%d)", shmId.toString(), slotIdx); } }
@Override public String toString() { return String.format("SlotId(%s:%d)", shmId.toString(), slotIdx); } }