コード例 #1
0
  private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {

    String tableName = null;

    List<Put> putList = null;

    for (int i = 0; i < listRestoreSelectedTables.getModel().getSize(); i++) {
      try {
        tableName = (String) listRestoreSelectedTables.getModel().getElementAt(i);
        listRestoreSelectedTables.setSelectedValue(tableName, true);
        hbTable = tableObjects.get(tableName);

        tableData = hbTable.getTableData();

        tableStructure = hbTable.getTableStructure();

        HTableDescriptor descriptor = tableStructure.createReadTableStructure();
        byte[][] family = createTable(descriptor);

        putList = createPutList(tableData, family);

        HbaseManagerTableGetter.setTable(tableStructure.getHTableName());
        HbaseManagerTableGetter._insert(putList);
        listRestoreSelectedTables.setSelectedValue(tableName, false);

      } catch (Exception e) {
        System.out.print("Restore of " + tableName + " Failed");
        break;
      }
    }
  }
コード例 #2
0
  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);
      }
    }
  }