@Override public void cleanup() { try { client.shutdown(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) { this.collector = outputCollector; client = new KuduClient.KuduClientBuilder(Constants.KUDU_MASTER).build(); try { this.table_attr = client.openTable(Constants.UPUSERS_ATTR_TABLE); this.table_days = client.openTable(Constants.UPUSERS_DAYS_TABLE); this.session = client.newSession(); // this.session.setMutationBufferSpace(32*1024*1024); // this.session.setTimeoutMillis(60*1000); // this.session.setFlushMode(KuduSession.FlushMode.AUTO_FLUSH_BACKGROUND); } catch (Exception e) { e.printStackTrace(); } }
/** 检查Session */ private void checkSession() { if (session.isClosed()) { System.out.println( "================================Session is closed ================================" + client); if (client == null) { client = new KuduClient.KuduClientBuilder(Constants.KUDU_MASTER).build(); } if (StringUtils.isNotEmpty(client.toString())) { try { table_attr = client.openTable(Constants.UPUSERS_ATTR_TABLE); table_days = client.openTable(Constants.UPUSERS_DAYS_TABLE); session = client.newSession(); } catch (Exception e) { e.printStackTrace(); } } System.out.println( "================================Session is created ================================" + client); } }