private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // HBaseTableManager tblmngr = HbaseManagerTableGetter.getTblManager(); byte[][] colFamilys; HashMap<String, String[][]> tableDataList; List<byte[]> rowKeyList = new ArrayList<byte[]>(); final JFileChooser fc = new JFileChooser(); fc.showSaveDialog(this); ObjectOutputStream writeObjectFile = null; try { // JOptionPane. fc.getSelectedFile().getName(); writeObjectFile = new ObjectOutputStream(new FileOutputStream(fc.getSelectedFile())); } catch (IOException ex) { Logger.getLogger(HbaseDataBackupRestoreDialog.class.getName()).log(Level.SEVERE, null, ex); } try { for (int i = 0; i < listSelectedTables.getModel().getSize(); i++) { String tblName = (String) listSelectedTables.getModel().getElementAt(i); // (String)listSelectedTables. listSelectedTables.setSelectedValue(tblName, true); Logger.getLogger(HbaseDataBackupRestoreDialog.class.getName()) .log(Level.INFO, "Table name: " + tblName); HBaseTableStructure tableStructure = new HBaseTableStructure(); tableStructure.createWriteTableStructure(tblName); colFamilys = tableStructure.getAllColoumnFamilies(); ResultScanner resultScan = HbaseManagerTableGetter.getAllFamilyList("0", "zz", colFamilys, tblName); tableDataList = getObjectList(resultScan, colFamilys, rowKeyList); // HbaseTbleObject ob; HbaseTableObject hbTable = new HbaseTableObject(); HBaseTableData tableData = new HBaseTableData(); tableData.setDbDataList(tableDataList); tableData.setRowKeylist(rowKeyList); hbTable.setTableData(tableData); hbTable.setTableStructure(tableStructure); writeObjectFile.writeObject(hbTable); listSelectedTables.setSelectedValue(tblName, false); } // write hbTable to file, object stream; } catch (IOException ex) { Logger.getLogger(HbaseDataBackupRestoreDialog.class.getName()).log(Level.SEVERE, null, ex); try { writeObjectFile.close(); } catch (IOException ex1) { Logger.getLogger(HbaseDataBackupRestoreDialog.class.getName()).log(Level.SEVERE, null, ex1); } } }
private List<Put> createPutList(HBaseTableData tableData, byte[][] family) { HashMap<String, String[][]> dataList = tableData.getDbDataList(); List<Put> putList = new ArrayList<Put>(); Put rowPut; String Data[][]; Set<String> keys = dataList.keySet(); String[] rowlist = new String[keys.size()]; keys.toArray(rowlist); String[] rowfamPair = new String[2]; for (int i = 0; i < rowlist.length; i++) { rowfamPair = rowlist[i].split(","); rowPut = new Put(Bytes.toBytes(rowfamPair[1])); Data = dataList.get(rowlist[i]); rowPut = preparePut(Data, rowfamPair[0], rowPut); System.out.println("Adding: " + rowfamPair[0]); putList.add(rowPut); } return putList; }