Examples of SessionState


Examples of org.apache.activemq.state.SessionState

    public Response processAddProducer(ProducerInfo info) throws Exception {
        SessionId sessionId = info.getProducerId().getParentId();
        ConnectionId connectionId = sessionId.getParentId();
        TransportConnectionState cs = lookupConnectionState(connectionId);
        SessionState ss = cs.getSessionState(sessionId);
        if (ss == null) {
            throw new IllegalStateException(
                                            "Cannot add a producer to a session that had not been registered: "
                                                + sessionId);
        }
        // Avoid replaying dup commands
        if (!ss.getProducerIds().contains(info.getProducerId())) {
            broker.addProducer(cs.getContext(), info);
            try {
                ss.addProducer(info);
            } catch (IllegalStateException e) {
                broker.removeProducer(cs.getContext(), info);
            }
        }
        return null;
View Full Code Here

Examples of org.apache.hadoop.hive.ql.session.SessionState

      if (tbl.getParameters() != null) {
        tbl.getParameters().remove(Constants.DDL_TIME);
      }
      org.apache.hadoop.hive.metastore.api.Table tTbl = tbl.getTTable();
      PrincipalPrivilegeSet principalPrivs = new PrincipalPrivilegeSet();
      SessionState ss = SessionState.get();
      if (ss != null) {
        CreateTableAutomaticGrant grants = ss.getCreateTableGrants();
        if (grants != null) {
          principalPrivs.setUserPrivileges(grants.getUserGrants());
          principalPrivs.setGroupPrivileges(grants.getGroupGrants());
          principalPrivs.setRolePrivileges(grants.getRoleGrants());
          tTbl.setPrivileges(principalPrivs);
View Full Code Here

Examples of org.apache.hadoop.hive.ql.session.SessionState

    }
    return metaStoreClient;
  }

  private String getUserName() {
    SessionState ss = SessionState.get();
    if (ss != null && ss.getAuthenticator() != null) {
      return ss.getAuthenticator().getUserName();
    }
    return null;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.session.SessionState

    }
    return null;
  }

  private List<String> getGroupNames() {
    SessionState ss = SessionState.get();
    if (ss != null && ss.getAuthenticator() != null) {
      return ss.getAuthenticator().getGroupNames();
    }
    return null;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.session.SessionState

  private void doAuthorization(BaseSemanticAnalyzer sem)
      throws HiveException, AuthorizationException {
    HashSet<ReadEntity> inputs = sem.getInputs();
    HashSet<WriteEntity> outputs = sem.getOutputs();
    SessionState ss = SessionState.get();
    HiveOperation op = ss.getHiveOperation();
    Hive db = sem.getDb();
    if (op != null) {
      if (op.equals(HiveOperation.CREATETABLE_AS_SELECT)
          || op.equals(HiveOperation.CREATETABLE)) {
        ss.getAuthorizer().authorize(
            db.getDatabase(db.getCurrentDatabase()), null,
            HiveOperation.CREATETABLE_AS_SELECT.getOutputRequiredPrivileges());
      }
      if (outputs != null && outputs.size() > 0) {
        for (WriteEntity write : outputs) {

          if (write.getType() == WriteEntity.Type.PARTITION) {
            Partition part = db.getPartition(write.getTable(), write
                .getPartition().getSpec(), false);
            if (part != null) {
              ss.getAuthorizer().authorize(write.getPartition(), null,
                      op.getOutputRequiredPrivileges());
              continue;
            }
          }

          if (write.getTable() != null) {
            ss.getAuthorizer().authorize(write.getTable(), null,
                    op.getOutputRequiredPrivileges());
          }
        }

      }
    }

    if (inputs != null && inputs.size() > 0) {

      Map<Table, List<String>> tab2Cols = new HashMap<Table, List<String>>();
      Map<Partition, List<String>> part2Cols = new HashMap<Partition, List<String>>();

      for (ReadEntity read : inputs) {
        boolean part = read.getPartition() != null;
        if (part) {
          part2Cols.put(read.getPartition(), new ArrayList<String>());
        } else {
          tab2Cols.put(read.getTable(), new ArrayList<String>());
        }
      }

      if (op.equals(HiveOperation.CREATETABLE_AS_SELECT)
          || op.equals(HiveOperation.QUERY)) {
        SemanticAnalyzer querySem = (SemanticAnalyzer) sem;
        ParseContext parseCtx = querySem.getParseContext();
        Map<TableScanOperator, Table> tsoTopMap = parseCtx.getTopToTable();

        for (Map.Entry<String, Operator<? extends Serializable>> topOpMap : querySem
            .getParseContext().getTopOps().entrySet()) {
          Operator<? extends Serializable> topOp = topOpMap.getValue();
          if (topOp instanceof TableScanOperator
              && tsoTopMap.containsKey(topOp)) {
            TableScanOperator tableScanOp = (TableScanOperator) topOp;
            Table tbl = tsoTopMap.get(tableScanOp);
            List<Integer> neededColumnIds = tableScanOp.getNeededColumnIDs();
            List<FieldSchema> columns = tbl.getCols();
            List<String> cols = new ArrayList<String>();
            if (neededColumnIds != null && neededColumnIds.size() > 0) {
              for (int i = 0; i < neededColumnIds.size(); i++) {
                cols.add(columns.get(neededColumnIds.get(i)).getName());
              }
            } else {
              for (int i = 0; i < columns.size(); i++) {
                cols.add(columns.get(i).getName());
              }
            }
            if (tbl.isPartitioned()) {
              String alias_id = topOpMap.getKey();
              PrunedPartitionList partsList = PartitionPruner.prune(parseCtx
                  .getTopToTable().get(topOp), parseCtx.getOpToPartPruner()
                  .get(topOp), parseCtx.getConf(), alias_id, parseCtx
                  .getPrunedPartitions());
              Set<Partition> parts = new HashSet<Partition>();
              parts.addAll(partsList.getConfirmedPartns());
              parts.addAll(partsList.getUnknownPartns());
              for (Partition part : parts) {
                part2Cols.put(part, cols);
              }
            } else {
              tab2Cols.put(tbl, cols);
            }
          }
        }
      }

      for (ReadEntity read : inputs) {
        if (read.getPartition() != null) {
          List<String> cols = part2Cols.get(read.getPartition());
          if (cols != null && cols.size() > 0) {
            ss.getAuthorizer().authorize(read.getPartition().getTable(),
                    read.getPartition(), cols, op.getInputRequiredPrivileges(),
                    null);
          } else {
            ss.getAuthorizer().authorize(read.getPartition(),
                    op.getInputRequiredPrivileges(), null);
          }
        } else if (read.getTable() != null) {
          List<String> cols = tab2Cols.get(read.getTable());
          if (cols != null && cols.size() > 0) {
            ss.getAuthorizer().authorize(read.getTable(), null, cols,
                    op.getInputRequiredPrivileges(), null);
          } else {
            ss.getAuthorizer().authorize(read.getTable(),
                    op.getInputRequiredPrivileges(), null);
          }
        }
      }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.session.SessionState

    }
  }

  private static int processCmd(String cmd){

    SessionState ss = SessionState.get();
    long start = System.currentTimeMillis();

    cmd = cmd.trim();
    String firstToken = cmd.split("\\s+")[0].trim();
View Full Code Here

Examples of org.apache.hadoop.hive.ql.session.SessionState

  @Override
  public CommandProcessorResponse run(String command) {

    int ret = super.run(command).getResponseCode();

    SessionState ss = SessionState.get();

    if (ret == 0){
      // Only attempt to do this, if cmd was successful.
      ret = setFSPermsNGrp(ss);
    }
    // reset conf vars
    ss.getConf().set(HowlConstants.HOWL_CREATE_DB_NAME, "");
    ss.getConf().set(HowlConstants.HOWL_CREATE_TBL_NAME, "");

    return new CommandProcessorResponse(ret);
  }
View Full Code Here

Examples of org.apache.jetspeed.services.statemanager.SessionState

                                          Context context,
                                          RunData rundata )
    {
        try {
       
            SessionState state = this.getSessionState(portlet, rundata);          
           
            String customizeEvent  = rundata.getParameters().getString(CUSTOMIZE_EVENT_PARAM);
           
            if (customizeEvent == null)
            {
              setTemplate(rundata, getParameterUsingFallback(portlet, rundata, CUSTOMIZE_TEMPLATE, null));
            }
            else
            {
                if (customizeEvent.equals(NEW_CATALOG_EVENT))
                {
                  this.doNewCatalog(portlet,context,rundata);
                }
           
                if (customizeEvent.equals(INSERT_CATALOG_EVENT))
                {
                  this.doInsertCatalog(portlet,context,rundata);
                }
            }
            // Store cataloPath and catalog into the context
            context.put(CATALOG_PATH_PARAM, state.getAttribute(CATALOG_PATH_PARAM));
            context.put(CATALOG_PARAM, state.getAttribute(CATALOG_PARAM));
        }
        catch (JetspeedCMSException e)
        {
            e.printStackTrace()
        }
View Full Code Here

Examples of org.apache.mina.core.session.SessionState

    private int removeSessions() {
        int removedSessions = 0;

        for (T session = removingSessions.poll();session != null;session = removingSessions.poll()) {
            SessionState state = getState(session);

            // Now deal with the removal accordingly to the session's state
            switch (state) {
                case OPENED:
                    // Try to remove this session
View Full Code Here

Examples of org.apache.mina.core.session.SessionState

            // Reset the Schedule for flush flag for this session,
            // as we are flushing it now
            session.unscheduledForFlush();
           
            SessionState state = getState(session);

            switch (state) {
                case OPENED:
                    try {
                        boolean flushedAll = flushNow(session, currentTime);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.