Package krati.util

Examples of krati.util.Chronos


       
        System.out.println(client.getSchema());
       
        String key;
        GenericRecord value;
        Chronos c = new Chronos();
       
        for(int i = 0; i < 10; i++) {
            key = "member." + i;
            value = client.get(key);
            System.out.println("get: " + key + "->" + value);
        }
       
        System.out.println(c.getElapsedTime());
       
        System.out.println();
        for(int i = 0; i < 10; i++) {
            System.out.println("position=" + client.getPosition());
            Thread.sleep(100);
        }
       
        System.out.println();
        for(int i = 0; i < 10; i++) {
            System.out.println("position=" + client.getPosition(Clock.ZERO));
            Thread.sleep(100);
        }
       
        Position position, nextPosition;
        Map<String, GenericRecord> map = new HashMap<String, GenericRecord>(1000);
       
        System.out.println();
        c.getElapsedTime();
       
        position = client.getPosition();
        for(int i = 0; i < 10; i++) {
            nextPosition = client.syncUp(position, map);
            System.out.printf("syncUp=%d position=%s in %s%n", map.size(), nextPosition.toString(), c.getElapsedTime());
            position = nextPosition;
            map.clear();
        }
       
        System.out.println();
        c.getElapsedTime();
       
        position = client.getPosition(Clock.ZERO);
        while(true) {
            nextPosition = client.syncUp(position, map);
            System.out.printf("syncUp=%d position=%s in %s%n", map.size(), nextPosition.toString(), c.getElapsedTime());
            if(map.size() == 0) break;
            position = nextPosition;
            map.clear();
        }
       
View Full Code Here


    public static void main(String[] args) throws Exception {
        URL url = new URL("http://localhost:8080");
        String source = "AvroStoreJoinerHttpServer";
        AvroStoreClientHttp<String> client = new AvroStoreClientHttp<String>(url, source, new StringSerializer());
       
        Chronos c = new Chronos();
       
        // get
        for(int i = 0; i < 100; i++) {
            String key = "member." + i;
            GenericRecord value = client.get(key);
            System.out.println("get: " + key + "->" + value);
        }
       
        System.out.println("total=" + c.getElapsedTime());
       
        // multi-get
        ArrayList<String> keys = new ArrayList<String>();
        for(int i = 0; i < 10; i++) {
            keys.add("member." + i);
        }
       
        Map<String, GenericRecord> map = client.get(keys);
        for(String key : keys) {
            System.out.println("mget: " + key + "->" + map.get(key));
        }
       
        System.out.println("mget: " + c.getElapsedTime());
       
        // multi-put
        client.put(map);
        System.out.println("mput: " + c.getElapsedTime());
       
        // multi-delete
        client.delete(keys);
        System.out.println("mdel: " + c.getElapsedTime());
       
        // multi-get
        Map<String, GenericRecord> map2 = client.get(keys);
        for(String key : keys) {
            System.out.println("mget: " + key + "->" + map2.get(key));
        }
       
        System.out.println("mget: " + c.getElapsedTime());
    }
View Full Code Here

        String source = "SingleAvroStoreHtterServerDemo";
        AvroStoreClientHttp<String> client = new AvroStoreClientHttp<String>(url, source, new StringSerializer());
       
        String key;
        GenericRecord value;
        Chronos c = new Chronos();
       
        // schema
        Schema schema = client.getSchema();
        System.out.println(schema.toString());
       
        // put
        for(int i = 0; i < 100; i++) {
            key = "member." + i;
            value = createRecord(schema, i);
            client.put(key, value);
            System.out.println("put: " + key + "->"  + value);
        }
        System.out.println(c.getElapsedTime());
       
        // get
        for(int i = 0; i < 100; i++) {
            key = "member." + i;
            value = client.get(key);
            System.out.println("get: " + key + "->"  + value);
        }
        System.out.println(c.getElapsedTime());
       
        // multi-put
        Map<String, GenericRecord> mputMap = new HashMap<String, GenericRecord>();
        for(int i = 100; i < 200; i++) {
            key = "member." + i;
            value = createRecord(schema, i);
            mputMap.put(key, value);
        }
       
        client.put(mputMap);
        System.out.println("mput: " + c.getElapsedTime() + " " + mputMap.size() + " records");
       
        // multi-get
        Map<String, GenericRecord> mgetMap = client.get(mputMap.keySet());
        System.out.println("mget: " + c.getElapsedTime() + " " + mgetMap.size() + " records");
    }
View Full Code Here

        // Change accordingly with the server
        int indexStart = 50000;
       
        Integer key;
        GenericRecord value;
        Chronos c = new Chronos();
       
        for(int i = 0; i < 10; i++) {
            key = indexStart + i;
            value = client.get(key);
            System.out.println("get: " + key + "->" + value);
        }
       
        System.out.println(c.getElapsedTime());
       
        System.out.println();
        for(int i = 0; i < 10; i++) {
            System.out.println("position=" + client.getPosition());
            Thread.sleep(100);
        }
       
        System.out.println();
        for(int i = 0; i < 10; i++) {
            System.out.println("position=" + client.getPosition(Clock.ZERO));
            Thread.sleep(100);
        }
       
        Position position, nextPosition;
        Map<Integer, GenericRecord> map = new HashMap<Integer, GenericRecord>(1000);
       
        System.out.println();
        c.getElapsedTime();
       
        position = client.getPosition();
        for(int i = 0; i < 10; i++) {
            nextPosition = client.syncUp(position, map);
            System.out.printf("syncUp=%d position=%s in %s%n", map.size(), nextPosition.toString(), c.getElapsedTime());
            position = nextPosition;
            map.clear();
        }
       
        System.out.println();
        c.getElapsedTime();
       
        position = client.getPosition(Clock.ZERO);
        while(true) {
            nextPosition = client.syncUp(position, map);
            System.out.printf("syncUp=%d position=%s in %s%n", map.size(), nextPosition.toString(), c.getElapsedTime());
            if(map.size() == 0) break;
            position = nextPosition;
            map.clear();
        }
       
View Full Code Here

  public void load(MemoryIntArray intArray) throws IOException {
    if (!_file.exists() || _file.length() == 0) {
      return;
    }
   
    Chronos c = new Chronos();
    DataReader r = IOFactory.createDataReader(_file, _type);
   
    try {
      r.open();
      r.position(DATA_START_POSITION);
     
      for (int i = 0; i < _arrayLength; i++) {
        intArray.set(i, r.readInt());
      }
     
      _log.info(_file.getName() + " loaded in " + c.getElapsedTime());
    } finally {
      r.close();
    }
  }
View Full Code Here

  public void load(MemoryLongArray longArray) throws IOException {
    if (!_file.exists() || _file.length() == 0) {
      return;
    }
   
    Chronos c = new Chronos();
    DataReader r = IOFactory.createDataReader(_file, _type);
   
    try {
      r.open();
      r.position(DATA_START_POSITION);
     
      for (int i = 0; i < _arrayLength; i++) {
        longArray.set(i, r.readLong());
      }
     
      _log.info(_file.getName() + " loaded in " + c.getElapsedTime());
    } finally {
      r.close();
    }
  }
View Full Code Here

  public void load(MemoryShortArray shortArray) throws IOException {
    if (!_file.exists() || _file.length() == 0) {
      return;
    }
   
    Chronos c = new Chronos();
    DataReader r = IOFactory.createDataReader(_file, _type);
   
    try {
      r.open();
      r.position(DATA_START_POSITION);
     
      for (int i = 0; i < _arrayLength; i++) {
        shortArray.set(i, r.readShort());
      }
     
      _log.info(_file.getName() + " loaded in " + c.getElapsedTime());
    } finally {
      r.close();
    }
  }
View Full Code Here

  public int[] loadIntArray() throws IOException {
    if (!_file.exists() || _file.length() == 0) {
      return null;
    }
   
    Chronos c = new Chronos();
    DataReader r = IOFactory.createDataReader(_file, _type);
   
    try {
      r.open();
      r.position(DATA_START_POSITION);
     
      int[] array = new int[_arrayLength];
      for (int i = 0; i < _arrayLength; i++) {
        array[i] = r.readInt();
      }
     
      _log.info(_file.getName() + " loaded in " + c.getElapsedTime());
      return array;
    } finally {
      r.close();
    }
  }
View Full Code Here

  public long[] loadLongArray() throws IOException {
    if (!_file.exists() || _file.length() == 0) {
      return null;
    }
   
    Chronos c = new Chronos();
    DataReader r = IOFactory.createDataReader(_file, _type);
   
    try {
      r.open();
      r.position(DATA_START_POSITION);
     
      long[] array = new long[_arrayLength];
      for (int i = 0; i < _arrayLength; i++) {
        array[i] = r.readLong();
      }
     
      _log.info(_file.getName() + " loaded in " + c.getElapsedTime());
      return array;
    } finally {
      r.close();
    }
  }
View Full Code Here

  public short[] loadShortArray() throws IOException {
    if (!_file.exists() || _file.length() == 0) {
      return null;
    }
   
    Chronos c = new Chronos();
    DataReader r = IOFactory.createDataReader(_file, _type);
   
    try {
      r.open();
      r.position(DATA_START_POSITION);
       
      short[] array = new short[_arrayLength];
      for (int i = 0; i < _arrayLength; i++) {
        array[i] = r.readShort();
      }
     
      _log.info(_file.getName() + " loaded in " + c.getElapsedTime());
      return array;
    } finally {
      r.close();
    }
  }
View Full Code Here

TOP

Related Classes of krati.util.Chronos

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.