Package org.apache.hadoop.hbase.regionserver

Examples of org.apache.hadoop.hbase.regionserver.OperationStatus


      LOG.info("Wrote " + ops.get() + " times in region " + regionName);
    }

    for (int i = 0; i < miniBatchOp.size(); i++) {
      miniBatchOp.setOperationStatus(i,
          new OperationStatus(HConstants.OperationStatusCode.SUCCESS));
    }
    c.bypass();
  }
View Full Code Here


      CellVisibility cellVisibility = null;
      try {
        cellVisibility = m.getCellVisibility();
      } catch (DeserializationException de) {
        miniBatchOp.setOperationStatus(i,
            new OperationStatus(SANITY_CHECK_FAILURE, de.getMessage()));
        continue;
      }
      if (m instanceof Put) {
        Put p = (Put) m;
        boolean sanityFailure = false;
        for (CellScanner cellScanner = p.cellScanner(); cellScanner.advance();) {
          if (!checkForReservedVisibilityTagPresence(cellScanner.current())) {
            miniBatchOp.setOperationStatus(i, new OperationStatus(SANITY_CHECK_FAILURE,
                "Mutation contains cell with reserved type tag"));
            sanityFailure = true;
            break;
          }
        }
        if (!sanityFailure) {
          if (cellVisibility != null) {
            String labelsExp = cellVisibility.getExpression();
            List<Tag> visibilityTags = labelCache.get(labelsExp);
            if (visibilityTags == null) {
              try {
                visibilityTags = createVisibilityTags(labelsExp);
              } catch (ParseException e) {
                miniBatchOp.setOperationStatus(i,
                    new OperationStatus(SANITY_CHECK_FAILURE, e.getMessage()));
              } catch (InvalidLabelException e) {
                miniBatchOp.setOperationStatus(i,
                    new OperationStatus(SANITY_CHECK_FAILURE, e.getMessage()));
              }
            }
            if (visibilityTags != null) {
              labelCache.put(labelsExp, visibilityTags);
              List<Cell> updatedCells = new ArrayList<Cell>();
              for (CellScanner cellScanner = p.cellScanner(); cellScanner.advance();) {
                Cell cell = cellScanner.current();
                List<Tag> tags = Tag.asList(cell.getTagsArray(), cell.getTagsOffset(),
                    cell.getTagsLength());
                tags.addAll(visibilityTags);
                Cell updatedCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(),
                    cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(),
                    cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(),
                    cell.getQualifierLength(), cell.getTimestamp(), Type.codeToType(cell
                        .getTypeByte()), cell.getValueArray(), cell.getValueOffset(),
                    cell.getValueLength(), tags);
                updatedCells.add(updatedCell);
              }
              p.getFamilyCellMap().clear();
              // Clear and add new Cells to the Mutation.
              for (Cell cell : updatedCells) {
                p.add(cell);
              }
            }
          }
        }
      } else if (cellVisibility != null) {
        // CellVisibility in a Delete is not legal! Fail the operation
        miniBatchOp.setOperationStatus(i, new OperationStatus(SANITY_CHECK_FAILURE,
            "CellVisibility cannot be set on Delete mutation"));
      }
    }
  }
View Full Code Here

      CellVisibility cellVisibility = null;
      try {
        cellVisibility = m.getCellVisibility();
      } catch (DeserializationException de) {
        miniBatchOp.setOperationStatus(i,
            new OperationStatus(SANITY_CHECK_FAILURE, de.getMessage()));
        continue;
      }
      if (m instanceof Put) {
        Put p = (Put) m;
        boolean sanityFailure = false;
        for (CellScanner cellScanner = p.cellScanner(); cellScanner.advance();) {
          if (!checkForReservedVisibilityTagPresence(cellScanner.current())) {
            miniBatchOp.setOperationStatus(i, new OperationStatus(SANITY_CHECK_FAILURE,
                "Mutation contains cell with reserved type tag"));
            sanityFailure = true;
            break;
          }
        }
        if (!sanityFailure) {
          if (cellVisibility != null) {
            String labelsExp = cellVisibility.getExpression();
            List<Tag> visibilityTags = labelCache.get(labelsExp);
            if (visibilityTags == null) {
              try {
                visibilityTags = createVisibilityTags(labelsExp);
              } catch (ParseException e) {
                miniBatchOp.setOperationStatus(i,
                    new OperationStatus(SANITY_CHECK_FAILURE, e.getMessage()));
              } catch (InvalidLabelException e) {
                miniBatchOp.setOperationStatus(i,
                    new OperationStatus(SANITY_CHECK_FAILURE, e.getMessage()));
              }
            }
            if (visibilityTags != null) {
              labelCache.put(labelsExp, visibilityTags);
              List<Cell> updatedCells = new ArrayList<Cell>();
              for (CellScanner cellScanner = p.cellScanner(); cellScanner.advance();) {
                Cell cell = cellScanner.current();
                List<Tag> tags = Tag.asList(cell.getTagsArray(), cell.getTagsOffset(),
                    cell.getTagsLength());
                tags.addAll(visibilityTags);
                Cell updatedCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(),
                    cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(),
                    cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(),
                    cell.getQualifierLength(), cell.getTimestamp(), Type.codeToType(cell
                        .getTypeByte()), cell.getValueArray(), cell.getValueOffset(),
                    cell.getValueLength(), tags);
                updatedCells.add(updatedCell);
              }
              p.getFamilyCellMap().clear();
              // Clear and add new Cells to the Mutation.
              for (Cell cell : updatedCells) {
                p.add(cell);
              }
            }
          }
        }
      } else if (cellVisibility != null) {
        // CellVisibility in a Delete is not legal! Fail the operation
        miniBatchOp.setOperationStatus(i, new OperationStatus(SANITY_CHECK_FAILURE,
            "CellVisibility cannot be set on Delete mutation"));
      }
    }
  }
View Full Code Here

      CellVisibility cellVisibility = null;
      try {
        cellVisibility = m.getCellVisibility();
      } catch (DeserializationException de) {
        miniBatchOp.setOperationStatus(i,
            new OperationStatus(SANITY_CHECK_FAILURE, de.getMessage()));
        continue;
      }
        boolean sanityFailure = false;
        for (CellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
          if (!checkForReservedVisibilityTagPresence(cellScanner.current())) {
            miniBatchOp.setOperationStatus(i, new OperationStatus(SANITY_CHECK_FAILURE,
                "Mutation contains cell with reserved type tag"));
            sanityFailure = true;
            break;
          }
        }
        if (!sanityFailure) {
          if (cellVisibility != null) {
            String labelsExp = cellVisibility.getExpression();
            List<Tag> visibilityTags = labelCache.get(labelsExp);
            if (visibilityTags == null) {
              try {
                visibilityTags = createVisibilityTags(labelsExp, true, auths, user.getShortName());
              } catch (ParseException e) {
                miniBatchOp.setOperationStatus(i,
                    new OperationStatus(SANITY_CHECK_FAILURE, e.getMessage()));
              } catch (InvalidLabelException e) {
                miniBatchOp.setOperationStatus(i,
                    new OperationStatus(SANITY_CHECK_FAILURE, e.getMessage()));
              }
            }
            if (visibilityTags != null) {
              labelCache.put(labelsExp, visibilityTags);
              List<Cell> updatedCells = new ArrayList<Cell>();
View Full Code Here

    List<Mutation> puts = new ArrayList<Mutation>(labels.size());
    int i = 0;
    for (byte[] label : labels) {
      String labelStr = Bytes.toString(label);
      if (this.labelsCache.getLabelOrdinal(labelStr) > 0) {
        finalOpStatus[i] = new OperationStatus(OperationStatusCode.FAILURE,
            new LabelAlreadyExistsException("Label '" + labelStr + "' already exists"));
      } else {
        Put p = new Put(Bytes.toBytes(ordinalCounter));
        p.addImmutable(LABELS_TABLE_FAMILY, LABEL_QUALIFIER, label, LABELS_TABLE_TAGS);
        if (LOG.isDebugEnabled()) {
View Full Code Here

    for (byte[] auth : authLabels) {
      String authStr = Bytes.toString(auth);
      int labelOrdinal = this.labelsCache.getLabelOrdinal(authStr);
      if (labelOrdinal == 0) {
        // This label is not yet added. 1st this should be added to the system
        finalOpStatus[i] = new OperationStatus(OperationStatusCode.FAILURE,
            new InvalidLabelException("Label '" + authStr + "' doesn't exists"));
      } else {
        Put p = new Put(Bytes.toBytes(labelOrdinal));
        p.addImmutable(LABELS_TABLE_FAMILY, user, DUMMY_VALUE, LABELS_TABLE_TAGS);
        puts.add(p);
View Full Code Here

        Delete d = new Delete(Bytes.toBytes(labelOrdinal));
        d.deleteColumns(LABELS_TABLE_FAMILY, user);
        deletes.add(d);
      } else {
        // This label is not set for the user.
        finalOpStatus[i] = new OperationStatus(OperationStatusCode.FAILURE,
            new InvalidLabelException("Label '" + authLabelStr + "' is not set for the user "
                + Bytes.toString(user)));
      }
      i++;
    }
View Full Code Here

      CellVisibility cellVisibility = null;
      try {
        cellVisibility = m.getCellVisibility();
      } catch (DeserializationException de) {
        miniBatchOp.setOperationStatus(i,
            new OperationStatus(SANITY_CHECK_FAILURE, de.getMessage()));
        continue;
      }
      boolean sanityFailure = false;
      for (CellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
        if (!checkForReservedVisibilityTagPresence(cellScanner.current())) {
          miniBatchOp.setOperationStatus(i, new OperationStatus(SANITY_CHECK_FAILURE,
              "Mutation contains cell with reserved type tag"));
          sanityFailure = true;
          break;
        }
      }
      if (!sanityFailure) {
        if (cellVisibility != null) {
          String labelsExp = cellVisibility.getExpression();
          List<Tag> visibilityTags = labelCache.get(labelsExp);
          if (visibilityTags == null) {
            // Don't check user auths for labels with Mutations when the user is super user
            boolean authCheck = this.checkAuths && !(isSystemOrSuperUser());
            try {
              visibilityTags = this.visibilityLabelService.createVisibilityExpTags(labelsExp, true,
                  authCheck);
            } catch (InvalidLabelException e) {
              miniBatchOp.setOperationStatus(i,
                  new OperationStatus(SANITY_CHECK_FAILURE, e.getMessage()));
            }
            if (visibilityTags != null) {
              labelCache.put(labelsExp, visibilityTags);
            }
          }
View Full Code Here

      Mutation m = mutation.getFirst();
      if (m instanceof Put) {
        try {
          prepareIndexMutations(indices, userRegion, m, tableName, indexRegion);
        } catch (IOException e) {
          mutation.setSecond(new OperationStatus(OperationStatusCode.SANITY_CHECK_FAILURE, e
              .getMessage()));
        }
      } else if (m instanceof Delete) {
        prepareIndexMutations(indices, userRegion, m, tableName, indexRegion);
      }
View Full Code Here

  public OperationStatus[] addLabels(List<byte[]> labels) throws IOException {
    // Not doing specific label add. We will just add labels in Mutation visibility expression as it
    // is along with every cell.
    OperationStatus[] status = new OperationStatus[labels.size()];
    for (int i = 0; i < labels.size(); i++) {
      status[i] = new OperationStatus(OperationStatusCode.SUCCESS);
    }
    return status;
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.OperationStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.