### Question:
Session implements Closeable { public Session(String host, int port, Configuration configuration) { this.host = host; this.port = port; this.configuration = configuration; } Session(String host, int port, Configuration configuration); void start(); PutResult put(DataPoint dataPoint); PutResult put(DataPoint dataPoint, boolean detailed); PutResult put(List<DataPoint> dataPoints, boolean sync, boolean detailed); List<QueryResult> query(Query query, HttpApiEndpoint api); List<QueryResult> query(Query query); List<QueryResult> queryExp(Query query); List<QueryResult> queryGexp(Query query); List<QueryResult> queryLast(Query query); TsdbVsersion version(); List<QueryResult> delete(Query query); boolean isRunning(); @Override void close();  }### Answer:
@Test public void testSession() throws Exception { Configuration configuration = new Configuration.Builder().build(); cluster = new Cluster.Builder().withAddress("localhost").withPort(4242) .withConfiguration(configuration).build(); Session session = cluster.connect(); Long ts = System.currentTimeMillis(); String metric = "metric"; HashMap<String, String> tags = new HashMap<>(); tags.put("tagk1", "tagv1"); tags.put("tagk2", "tagv2"); DataPoint dataPoint = new DataPoint.Builder().setMetric(metric).setTimestamp(ts) .setTags(tags).setValue(12333).build(); try { PutResult putResult = session.put(dataPoint); } catch (Exception e) { assertTrue(e.getMessage().contains("RetryOverException")); throw new Exception("put exception"); } finally { try { session.close(); } catch (IOException e) { throw new IOException("Session close make io exception"); } } try { session = cluster.connect(); TsdbVsersion vsersion = session.version(); } catch (Exception e) { throw new Exception("get tsdb version throw exception"); } finally { try { session.close(); } catch (IOException e) { throw new IOException("Session close make io exception"); } } List<Filter> filters = new ArrayList<>(); Filter filter = new Filter.Builder().setType(FilterType.wildcard).setTagk("tagk1") .setFilter("tag*").build(); filters.add(filter); MetricQuery metricQuery = new MetricQuery.Builder().metric("metric").downsample("5m-avg") .aggregator(Aggregator.max).rate().explicittags(false).filters(filters).tags(tags) .build(); List<MetricQuery> metricQueries = new ArrayList<>(); metricQueries.add(metricQuery); Query query = new Query.Builder().start(ts).sub(metricQueries).build(); try { session = cluster.connect(); List<QueryResult> queryResult = session.query(query); } catch (Exception e) { e.printStackTrace(); throw new Exception("query exception" + e.getMessage()); } finally { try { session.close(); } catch (IOException e) { e.printStackTrace(); throw new IOException("Session close make io exception"); } } MetricQuery metricQueryDelete = new MetricQuery.Builder().metric("metric").downsample("5m-avg") .aggregator(Aggregator.max).rate().explicittags(false).filters(filters).tags(tags) .build(); List<MetricQuery> metricQueriesDelete = new ArrayList<>(); metricQueriesDelete.add(metricQueryDelete); Query delete = new Query.Builder().start(ts).sub(metricQueriesDelete).build(); try { session = cluster.connect(); List<QueryResult> queryResult = session.delete(delete); } catch (Exception e) { e.printStackTrace(); throw new Exception("delete exception"); } finally { try { session.close(); } catch (IOException e) { e.printStackTrace(); throw new IOException("Session close make io exception"); } } }