public void testChangeCompression() 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); Point px = ClientHelper.client().getPoint(name); Assert.assertNotNull(px); px.setFilterValue(2.0); ClientHelper.client().updatePoint(px); Point px2 = ClientHelper.client().getPoint(name); Assert.assertEquals(2.0, px2.getFilterValue()); Assert.assertEquals(px.getKey(), px2.getKey()); try { Thread.sleep(1000); } catch (InterruptedException e) { fail(); } // double x2 = testCompression(p); ClientHelper.client().deletePoint(name); // Assert.assertEquals(255.0, x2); // gClient.DeletePoint(p.getValue()); }
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(); } }
@Test public void testCompression() throws NimbitsException { Point p = PointModelFactory.createPointModel(null); EntityName name = (CommonFactoryLocator.getInstance().createName("test" + UUID.randomUUID().toString())); p.setFilterValue(2.0); Point result = ClientHelper.client().addPoint(name, p); assertNotNull(result); Point test = ClientHelper.client().getPoint(name); assertNotNull(test); double x = testCompression(name); // Assert.assertEquals(255.0, x); // ClientHelper.client().deletePoint(p.getName()); }
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 testNoCompression() throws Exception { final Point p = PointModelFactory.createPointModel(null); final EntityName name = CommonFactoryLocator.getInstance() .createName("test" + UUID.randomUUID().toString(), EntityType.point); p.setExpire(1); p.setFilterValue(0); final Point point = ClientHelper.client().addPoint(name, p); assertNotNull(point); final double x = testCompression(name); ClientHelper.client().deletePoint(name); Assert.assertEquals(345.0, x); // gClient.DeletePoint(p.getValue()); }
private static double testCompression(final EntityName name) throws NimbitsException { double retVal = 0.0; Value vx; try { for (int i = 0; i < 40; i++) { Thread.sleep(10); vx = ClientHelper.client().recordValue(name, i, new Date()); assertNotNull(vx); } // Thread.sleep(2000); final List<Value> v = ClientHelper.client().getSeries(name, 10); for (final Value x : v) { retVal += x.getDoubleValue(); } } catch (InterruptedException e) { } System.out.println("End compression integration test " + retVal); return retVal; }
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(); // // }