public void testCompressionSeperateAlternatingValuesPostsNoDate() throws Exception { Point p = PointModelFactory.createPointModel(null); EntityName name = (CommonFactoryLocator.getInstance() .createName("test" + UUID.randomUUID().toString(), EntityType.point)); p.setFilterValue(0.1); Point result = ClientHelper.client().addPoint(name); assertNotNull(result); double rx = 0.0; try { for (int i = 0; i < 40; i++) { StringBuilder b = new StringBuilder(); if (rx == 0.0) { rx = 1.0; } else { rx = 0.0; } b.append("&p2=") .append(URLEncoder.encode(name.getValue(), Const.CONST_ENCODING)) .append("&v2=") .append(rx); // System.out.println( b.toString()); System.out.println(ClientHelper.client().recordBatch(b.toString())); Thread.sleep(100); } Thread.sleep(3000); List<Value> v = ClientHelper.client().getSeries(name, 40); double retVal = 0.0; for (Value x : v) { retVal += x.getDoubleValue(); } DecimalFormat twoDForm = new DecimalFormat("#.##"); retVal = Double.valueOf(twoDForm.format(retVal)); ClientHelper.client().deletePoint(name); Assert.assertEquals(20.0, retVal); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void testCompressionSeparatePostsNoDate() throws Exception { Point p = PointModelFactory.createPointModel(null); EntityName name = (CommonFactoryLocator.getInstance() .createName("test" + UUID.randomUUID().toString(), EntityType.point)); p.setFilterValue(0.1); ClientHelper.client().addPoint(name); double rx = 0.0; try { for (int i = 0; i < 40; i++) { StringBuilder b = new StringBuilder(); rx += 0.1; b.append("&p1=") .append(URLEncoder.encode(name.getValue(), Const.CONST_ENCODING)) .append("&v1=") .append(rx); // System.out.println( b.toString()); ClientHelper.client().recordBatch(b.toString()); System.out.println(rx); Thread.sleep(1000); } Thread.sleep(2000); List<Value> v = ClientHelper.client().getSeries(name.getValue(), 10); double retVal = 0.0; for (Value x : v) { retVal += x.getDoubleValue(); System.out.println(x.getDoubleValue()); } DecimalFormat twoDForm = new DecimalFormat("#.##"); retVal = Double.valueOf(twoDForm.format(retVal)); ClientHelper.client().deletePoint(name.getValue()); assertEquals(30.0, retVal, 0.0); } catch (IOException e) { } catch (InterruptedException e) { } }
public void TestZeroCompressionWithBatch() throws NimbitsException { Point p = PointModelFactory.createPointModel(null); EntityName name = (CommonFactoryLocator.getInstance() .createName("test" + UUID.randomUUID().toString(), EntityType.point)); p.setFilterValue(0.0); ClientHelper.client().addPoint(name, p); System.out.println( "Starting batch compression integration test compression = " + p.getFilterValue()); StringBuilder b = new StringBuilder(); try { for (int i = 0; i < 40; i++) { b.append("&p") .append(i) .append("=") .append(URLEncoder.encode(name.getValue(), Const.CONST_ENCODING)) .append("&v") .append(i) .append("=") .append(i) .append("&t") .append(i) .append("=") .append(new Date().getTime()); Thread.sleep(100); } System.out.println(b.toString()); System.out.println(ClientHelper.client().recordBatch(b.toString())); double retVal = 0.0; Thread.sleep(1000); List<Value> v = ClientHelper.client().getSeries(name, 10); for (Value x : v) { retVal += x.getDoubleValue(); System.out.println(x.getDoubleValue() + " " + x.getTimestamp()); } Assert.assertEquals(345.0, retVal); ClientHelper.client().deletePoint(name); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } // String ba = "&email=" + email + "&secret=" + secret + // "&p1=" + URLEncoder.encode("b1", Const.CONST_ENCODING)+ "&v1=" + r.nextDouble() + // "&p2=" + URLEncoder.encode("b2", Const.CONST_ENCODING)+ "&v2=" + r.nextDouble() + // "&p3=" + URLEncoder.encode("b3", Const.CONST_ENCODING)+ "&v3=" + r.nextDouble() + // "&p4=" + URLEncoder.encode("b4", Const.CONST_ENCODING)+ "&v4=" + r.nextDouble() + // "&p5=" + URLEncoder.encode("b5", Const.CONST_ENCODING)+ "&v5=" + r.nextDouble() + // "&p6=" + URLEncoder.encode("b6", Const.CONST_ENCODING)+ "&v6=" + r.nextDouble() + // "&p7=" + URLEncoder.encode("b7", Const.CONST_ENCODING)+ "&v7=" + r.nextDouble(); // // }