Package net.openhft.collections

Examples of net.openhft.collections.SharedHashMapBuilder


    public static final String TEST_KEY = "whatever";
    public static int NUMBER_OF_PROCESSES_ALLOWED = 2;

    public static void main(String[] args) throws Exception {
        //First create (or access if already created) the shared map
        SharedHashMapBuilder builder = new SharedHashMapBuilder()
                .entries(1000);

        //// don't include this, just to check it is as expected.
        assertEquals(8, builder.minSegments());
        //// end of test

        String shmPath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "SHMTest5";
        SharedHashMap<String, SHMTest5Data> theSharedMap = builder.file(new File(shmPath)).kClass(String.class).vClass(SHMTest5Data.class).create();

        //Now get the shared data object, auto-creating if it's not there
        SHMTest5Data data = DataValueClasses.newDirectReference(SHMTest5Data.class);
        theSharedMap.acquireUsing(TEST_KEY, data);
        //if this was newly created, we need to set the max allowed
View Full Code Here


  public static void main(String[] args) throws Exception
  {
    AtomicLong alValue = new AtomicLong();
    AtomicLong alKey = new AtomicLong();
    int runs = 3000000;
        SharedHashMapBuilder builder = new SharedHashMapBuilder().entries(runs);
        String shmPath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "SHMTestIterator1";
        SharedHashMap<String, Long> shm = builder.create(new File(shmPath), String.class, Long.class);
        /*shm.put("k1", alValue.incrementAndGet());
        shm.put("k2", alValue.incrementAndGet());
        shm.put("k3", alValue.incrementAndGet());
        shm.put("k4", alValue.incrementAndGet());
        shm.put("k5", alValue.incrementAndGet());*/
 
View Full Code Here

   *             - if the default shared file cannot be created
   */
  public ProcessInstanceLimiter(String sharedMapPath, Callback callback) throws IOException {
    this.sharedMapPath = sharedMapPath;
    this.callback = callback;
    SharedHashMapBuilder builder = new SharedHashMapBuilder();
    builder.entries(1000);
    builder.entrySize(1024);
        this.theSharedMap = builder.file(new File(sharedMapPath)).kClass(String.class).vClass(Data.class).create();
    Thread t = new Thread(this, "ProcessInstanceLimiter updater");
    t.setDaemon(true);
    t.start();
  }
View Full Code Here

        SharedHashMap<Integer, StateMachineData> map = null;

        try {
            File dataFile = new File(System.getProperty("java.io.tmpdir"),"hft-state-machine");

            map = new SharedHashMapBuilder()
                    .entries(8).file(dataFile).kClass(Integer.class).vClass(StateMachineData.class).create();

            if(args.length > 0) {
                if("0".equalsIgnoreCase(args[0])) {
                    StateMachineData smd =
View Full Code Here

TOP

Related Classes of net.openhft.collections.SharedHashMapBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.