Package com.sun.messaging.jmq.util.log

Examples of com.sun.messaging.jmq.util.log.Logger


    public static boolean authenticateCMDUserIfset() {
        BrokerConfig bcfg = Globals.getConfig();
        String cmduser = bcfg.getProperty(CMDUSER_PROPERTY);
        if (cmduser == nullreturn true;

        Logger logger = Globals.getLogger();
        BrokerResources rb = Globals.getBrokerResources();
        if (cmduser.trim().length() == 0) {
            logger.log(Logger.FORCE, rb.X_BAD_PROPERTY_VALUE,
                                     CMDUSER_PROPERTY+ "=" + cmduser);
            return false;
        }
            /*
            if (!bcfg.getBooleanProperty(Globals.KEYSTORE_USE_PASSFILE_PROP)) {
                logger.log(Logger.FORCE, rb.E_AUTH_CMDUSER_PASSFILE_NOT_ENABLED,
                           Globals.KEYSTORE_USE_PASSFILE_PROP, cmduserProp);
                return false;
            }
            */
        String cmdpwd = bcfg.getProperty(CMDUSER_PWD_PROPERTY);
        if (cmdpwd == null) {
            logger.log(Logger.FORCE, rb.X_PASSWORD_NOT_PROVIDED,
                                     CMDUSER_PROPERTY+"="+cmduser);
            return false;
        }
        String cmdsvc = bcfg.getProperty(CMDUSER_SVC_PROPERTY);
        if (cmdsvc == null) cmdsvc = "admin";
        List activesvcs= ServiceManager.getAllActiveServiceNames();
        if (activesvcs == null || !activesvcs.contains(cmdsvc)) {
            logger.log(Logger.FORCE, rb.E_NOT_ACTIVE_SERVICE, cmdsvc,
                                     CMDUSER_PROPERTY+"="+cmduser);
            return false;
        }
        String str = ServiceManager.getServiceTypeString(cmdsvc);
        if (str == null || ServiceType.getServiceType(str) != ServiceType.ADMIN) {
            String args[] = {cmdsvc, str, CMDUSER_PROPERTY+"="+cmduser};
            logger.log(Logger.FORCE, rb.E_NOT_ADMIN_SERVICE, args);
            return false;
        }
        try {
            MQAuthenticator a = new MQAuthenticator(cmdsvc, ServiceType.ADMIN);
            a.authenticate(cmduser, cmdpwd);
            if (DEBUG) {
            logger.log(Logger.FORCE, rb.I_AUTH_OK,
                       CMDUSER_PROPERTY+"="+cmduser, cmdsvc);
            }
            return true;
        } catch (Exception e) {
            if (DEBUG) {
            logger.logStack(Logger.FORCE, rb.W_AUTH_FAILED, cmduser, cmdsvc, e);
            } else {
            logger.log(Logger.FORCE, rb.W_AUTH_FAILED, cmduser, cmdsvc);
            }
            return false;
        }
    }
View Full Code Here


                                                  boolean redeliver,
                                                  TransactionUID tid,
                                                  TransactionList translist)
                                                  throws  BrokerException {

        Logger logger = Globals.getLogger();

        Iterator sitr = sendMap.entrySet().iterator();
        while (sitr.hasNext()) {
            Map.Entry entry = (Map.Entry)sitr.next();
            ConsumerUID intid = (ConsumerUID)entry.getKey();
            ConsumerUID storedID =(ConsumerUID) sToCmap.get(intid);

            SortedSet ss = (SortedSet)entry.getValue();
            Iterator itr = ss.iterator();
            while (itr.hasNext()) {
                PacketReference ref = (PacketReference)itr.next();
                SysMessageID sysid = ref.getSysMessageID();
                if (!ref.isLocal()) {
                    if (tid != null && translist != null) {
                        translist.removeOrphanAck(tid, sysid, storedID, intid);
                    }
                   
                    try {
                        if (ref.acknowledged(intid, storedID,
                                             !(intid.isNoAck()||intid.isDupsOK()),
                                             false, tid, null, false)) {
                            Destination d = ref.getDestination();
                            d.removeRemoteMessage(sysid, RemoveReason.ACKNOWLEDGED, ref);
                        }
                    } catch(Exception ex) {
                        logger.logStack((DEBUG_CLUSTER_TXN ? Logger.WARNING:Logger.DEBUG),
                                        "Unable to cleanup remote message "+
                                        "[" + intid + "," + storedID + "," + sysid+"]"+
                                        " on rollback transaction " +tid+" for inactive consumer.", ex);
                    }
                    BrokerAddress addr = null;
                    if (tid != null && translist != null) {
                        addr = translist.getAckBrokerAddress(tid, sysid, intid);
                    } else {
                        addr = ref.getAddress();
                    }
                    try {
                        HashMap prop = new HashMap();
                        if (tid != null) {
                            prop.put(ClusterBroadcast.RB_RELEASE_MSG_INACTIVE, tid.toString());
                        } else {
                            prop.put(ClusterBroadcast.RC_RELEASE_MSG_INACTIVE, "");
                        }
                        Globals.getClusterBroadcast().acknowledgeMessage(
                                                      addr, sysid, intid,
                                                      ClusterBroadcast.MSG_IGNORED,
                                                      prop, false /*no wait ack*/);
                    } catch (BrokerException e) {
                        Globals.getLogger().log(Logger.WARNING,
                        "Unable to notify "+addr+" for remote message "+
                        "["+intid+", "+storedID+", "+", "+sysid+"]"+
                        " in "+(tid != null ? ("rollback transaction "+ tid):("recover"))+" for inactive consumer.");
                    }
                    itr.remove();
                    continue;
                }
            }

            if (storedID == null || intid == storedID) {
                    // non-durable subscriber
                    // ignore
                    sitr.remove();
                   continue;
            }

            if (ss.isEmpty()) {
                if (DEBUG) {
                    logger.log(Logger.INFO, "redeliverUnackedNoConsuemr: "+
                    "empty local message set for consumer "+intid+"[storedID="+storedID+"]");
                }
                continue;
            }

            // see if we are a queue
            if (storedID == PacketReference.getQueueUID()) {
                // queue message on
                // queues are complex ->
                PacketReference ref = (PacketReference)ss.first();

                if (ref == null) {
                    if (DEBUG) {
                        logger.log(Logger.INFO,"Internal Error: "
                           + " null reterence");
                    }
                    continue;
                }
                try {
                    if (redeliver) {
                        ref.consumed(storedID, false, false);
                    } else {
                        ref.removeDelivered(storedID, false);
                    }
                } catch (IOException ex) {
                    logger.log(Logger.WARNING,"Internal error",
                           ex);
                }

                Destination d= ref.getDestination();
                if (d == null) {
                    if (DEBUG) {
                        logger.log(Logger.INFO,"Internal Error: "
                           + " unknown destination for reference: "
                           + ref);
                    }
                    continue;
                }

                // route each message to the destination
                // this puts it on the pending list
                try {
                    d.forwardOrphanMessages(ss, storedID);
                    sitr.remove();
                } catch (Exception ex) {
                    logger.log(Logger.INFO,"Internal Error: "
                               + "Unable to re-queue message "
                               + " to queue " + d, ex);
                }
            } else { // durable
                // ok - requeue the message on the subscription
                Consumer cs = Consumer.getConsumer(storedID);
                if (cs == null) {
                    if (DEBUG) {
                        logger.log(Logger.INFO,"Internal Error: "
                           + " unknown consumer " + storedID);
                    }
                    continue;
                }
                if (ss != null && !ss.isEmpty() &&
                     cs.routeMessages(ss, true /* toFront*/)) {
                    // successful
                    sitr.remove();
                }
            }
        }
        if (DEBUG && sendMap.size() > 0) {
            logger.log(Logger.INFO,tid + ":after all processing, " +
                sendMap.size() + " inactive consumers remaining");
        }

    }
View Full Code Here

    public static void compactAllDestinations() throws BrokerException  {
        Iterator itr = Destination.getAllDestinations();
        boolean docompact = true;
  String errMsg = null;
  BrokerResources rb = Globals.getBrokerResources();
  Logger logger = Globals.getLogger();

        while (itr.hasNext()) {
            // make sure all are paused
            Destination d = (Destination)itr.next();
View Full Code Here

    public static void createDestination(DestinationInfo info) throws BrokerException {
        String errMsg = null;
        int status = Status.OK;
  BrokerResources rb = Globals.getBrokerResources();
  Logger logger = Globals.getLogger();

        // Default attributes of the destination
        int type = DestType.DEST_TYPE_QUEUE | DestType.DEST_FLAVOR_SINGLE;
        int maxMessages = -1;
        SizeString maxMessageBytes = null;
        SizeString maxMessageSize = null;

        if (MemoryGlobals.MEM_DISALLOW_CREATE_DEST) {
            status = Status.ERROR;
            errMsg = rb.W_LOW_MEM_REJECT_DEST;
        } else if (info.isModified(DestinationInfo.NAME)) {
            if (info.isModified(DestinationInfo.TYPE)) {
                type = info.type;
            }
            if (info.isModified(DestinationInfo.MAX_MESSAGES)) {
                maxMessages = info.maxMessages;
            }
            if (info.isModified(DestinationInfo.MAX_MESSAGE_BYTES)) {
                maxMessageBytes = new SizeString();
                maxMessageBytes.setBytes(info.maxMessageBytes);
            }
            if (info.isModified(DestinationInfo.MAX_MESSAGE_SIZE)) {
                maxMessageSize = new SizeString();
                maxMessageSize.setBytes(info.maxMessageSize);
            }

        } else {
            status = Status.ERROR;
            errMsg = rb.X_NO_DEST_NAME_SET;
        }
        //
        //XXX create destination
        if (status == Status.OK) {

            if (DestType.destNameIsInternal(info.name)) {
                status = Status.ERROR;
                errMsg =  rb.getKString( rb.X_CANNOT_CREATE_INTERNAL_DEST,
                            info.name,
          DestType.INTERNAL_DEST_PREFIX);
      } else  {
                if (CreateDestinationHandler.isValidDestinationName(info.name)) {

                    try {
                        Destination.createDestination(info.name,
                          type);
                    } catch (Exception ex) {
                        status = Status.ERROR;
                        errMsg =  rb.getString( rb.X_CREATE_DEST_EXCEPTION,
                            info.name, getMessageFromException(ex));
                       if (ex instanceof ConflictException)
                           logger.log(Logger.INFO, errMsg, ex);
                       else
                           logger.logStack(Logger.INFO, errMsg, ex);
                    }
                } else {
                    status = Status.ERROR;
                    errMsg =  rb.getKString( rb.X_DEST_NAME_INVALID,
                            info.name);
                }
      }
        }

        if (status == Status.OK) {
            try {

                Destination d = Destination.getDestination(info.name, DestType.isQueue(type));

                d.setCapacity(maxMessages);
                d.setByteCapacity(maxMessageBytes);
                d.setMaxByteSize(maxMessageSize);
                if (info.isModified(info.DEST_SCOPE)) {
                    int scope = info.destScope;
                    d.setScope(scope)
                }
                if (info.isModified(info.DEST_LIMIT)) {
                    int destlimit = info.destLimitBehavior;
                    d.setLimitBehavior(destlimit);
                }
                if (info.isModified(info.DEST_PREFETCH)) {
                    int prefetch = info.maxPrefetch;
                    d.setMaxPrefetch(prefetch);
                }
                if (info.isModified(info.DEST_CDP)) {
                    int clusterdeliverypolicy = info.destCDP;
                    d.setClusterDeliveryPolicy(clusterdeliverypolicy);
                }
                if (info.isModified(info.MAX_ACTIVE_CONSUMERS)) {
                    int maxcons = info.maxActiveConsumers;
                    d.setMaxActiveConsumers(maxcons);
                }
                if (info.isModified(info.MAX_PRODUCERS)) {
                    int maxp = info.maxProducers;
                    d.setMaxProducers(maxp);
                }
                if (info.isModified(info.MAX_FAILOVER_CONSUMERS)) {
                    int maxcons = info.maxFailoverConsumers;
                    d.setMaxFailoverConsumers(maxcons);
                }
                if (info.isModified(info.MAX_SHARED_CONSUMERS)) {
                    int maxsharedcons = info.maxNumSharedConsumers;
                    d.setMaxSharedConsumers(maxsharedcons);
                }
                if (info.isModified(info.SHARE_FLOW_LIMIT)) {
                    int sflowlimit = info.sharedConsumerFlowLimit;
                    d.setSharedFlowLimit(sflowlimit);
                }
                if (info.isModified(info.USE_DMQ)) {
                    boolean dmq = info.useDMQ;
                    d.setUseDMQ(dmq);
                }
                d.update();
             
    /*
    // audit logging for create destination
    Globals.getAuditSession().destinationOperation(
      con.getUserName(), con.remoteHostString(),
      MQAuditSession.CREATE_DESTINATION,
      d.isQueue()?MQAuditSession.QUEUE:MQAuditSession.TOPIC,
      d.getDestinationName());
    */

            } catch (Exception ex) {

                // remove the destination
                try {
                    DestinationUID duid = DestinationUID.getUID(
                        info.name, DestType.isQueue(type));
                    Destination.removeDestination(duid, false, ex.toString());
                } catch (Exception ex1) {
                    // if we cant destroy .. its ok .. ignore the exception
                }

                status = Status.ERROR;
                errMsg = rb.getString( rb.X_UPDATE_DEST_EXCEPTION,
                            info.name, getMessageFromException(ex));

                logger.log(Logger.WARNING, errMsg, ex);

            }
        }

  if (status != Status.OK)  {
View Full Code Here

        boolean need = false;
        String svcname = null;
        String svctype = null;
        AccessController ac = null;
        BrokerConfig bcfg = Globals.getConfig();
        Logger logger = Globals.getLogger();

        String pp = null, svcpp = null;
        List activesvcs= ServiceManager.getAllActiveServiceNames();
        Iterator itr = activesvcs.iterator();
        while (itr.hasNext()) {
            svcname = (String)itr.next();
            svctype = ServiceManager.getServiceTypeString(svcname);
            if (svctype == null) {
                throw new BrokerException("Can't get service type for service "+svcname);
            }
          
            ac = AccessController.getInstance(svcname, ServiceType.getServiceType(svctype));
            if (!ac.isAccessControlEnabled()) continue;
            if (ac.getAccessControlType().equals(JAASAccessControlModel.TYPE)) {
                need = true;
                svcpp = ac.getAuthProperties().getProperty(
                                  AccessController.PROP_ACCESSCONTROL_PREFIX+
                                  JAASAccessControlModel.PROP_POLICY_PROVIDER) ;
                if (pp == null) {
                    pp = svcpp;
                    continue;
                }
                if (svcpp == null) continue;
                if (!pp.equals(svcpp)) {
                    throw new BrokerException("XI18N - Multiple Java policy providers is not allowed:"
                                               +pp+", "+svcpp);
                }                             
            }
        }
        if (!need) return;

        Policy ppc = null;
        if (pp != null) {
            try {
                ppc = (Policy)Class.forName(pp).newInstance();
            } catch (Exception e) {
                throw new BrokerException(e.getClass().getName()+": "+
                      e.getMessage()+" - "+
                      AccessController.PROP_ACCESSCONTROL_PREFIX+
                      JAASAccessControlModel.PROP_POLICY_PROVIDER+"="+pp);
            }
        }

        synchronized(System.class) {
            if (System.getSecurityManager() == null) {
                String val = System.getProperty("java.security.policy");
                if (val == null) {
                    /*
                    logger.log(logger.INFO, "Set java.security.policy to MQ default policy file");
                    System.setProperty("java.security.policy",
                    "file:"+Globals.getInstanceEtcDir()+File.separator+DEFAULT_POLICY_FILENAME);
                    */
                } else {
                    logger.log(logger.INFO, "java.security.policy="+val);
                }
                System.setSecurityManager(new SecurityManager());
                logger.log(logger.INFO, Globals.getBrokerResources().getKString(
                                  BrokerResources.I_SET_DEFAULT_SECURITY_MANAGER));
            }
        }
        if (ppc != null) {
            logger.log(logger.INFO, AccessController.PROP_ACCESSCONTROL_PREFIX+
                                    JAASAccessControlModel.PROP_POLICY_PROVIDER+"="+pp);
            Policy.setPolicy(ppc);
            logger.log(logger.INFO, Globals.getBrokerResources().getKString(
                    BrokerResources.I_SET_JAVA_POLICY_PROVIDER, ppc.getClass().getName()));
        }
    }
View Full Code Here

     * @return  a Store
     * @exception BrokerException  if it fails to instantiate a Store
     *          instance
     */
    public static synchronized Store getStore() throws BrokerException {
        Logger logger = Globals.getLogger();
        BrokerResources br = Globals.getBrokerResources();

        if (store == null) {
            // Can't open the store if we are shutting down
            if (BrokerStateHandler.shuttingDown) {
                throw new BrokerException(
                   Globals.getBrokerResources().getKString(
                       BrokerResources.X_SHUTTING_DOWN_BROKER),
                   BrokerResources.X_SHUTTING_DOWN_BROKER);
            }

      BrokerConfig config = Globals.getConfig();

      String type = config.getProperty(STORE_TYPE_PROP,
          DEFAULT_STORE_TYPE);
      if (Store.getDEBUG()) {
    logger.log(logger.DEBUG, STORE_TYPE_PROP + "=" + type);
      }

      String classname = config.getProperty(
        PERSIST_PROP + type + CLASS_PROP);
     
        isConfiguredFileStore = new Boolean(false);
      if (classname == null || classname.equals("")) {
    if (type.equals(Store.FILE_STORE_TYPE)) {
        classname = DEFAULT_FILESTORE_CLASS;
            isConfiguredFileStore = new Boolean(true);
    } else if (type.equals(Store.JDBC_STORE_TYPE))
        classname = DEFAULT_JDBCSTORE_CLASS;
    else if (type.equals(Store.INMEMORY_STORE_TYPE))
        classname = DEFAULT_INMEMORYSTORE_CLASS;
    else
        classname = null;
      }

      if (classname == null) {
    throw new BrokerException(
                    br.getString(br.E_BAD_STORE_TYPE, type));
      } else {
    if (Store.getDEBUG()) {
        logger.log(logger.DEBUG,
      PERSIST_PROP + type + CLASS_PROP + "=" + classname);
    }
      }

      try {
                boolean reload = false;
                do {
                    store = (Store)Class.forName(classname).newInstance();
                    //store.init();
                    txnLogEnabled = new Boolean(config.getBooleanProperty(TXNLOG_ENABLED_PROP, false));
                    newTxnLogEnabled = new Boolean(config.getBooleanProperty(
                                       NEW_TXNLOG_ENABLED_PROP, NEW_TXNLOG_ENABLED_PROP_DEFAULT));
                     if (!isConfiguredFileStore.booleanValue()) {
                        if (txnLogEnabled.booleanValue()) {
                            logger.log(Logger.WARNING, Globals.getBrokerResources().getKString(
                            BrokerResources.W_PROP_SETTING_TOBE_IGNORED, TXNLOG_ENABLED_PROP+"=true"));
                        }                       
                        if (newTxnLogEnabled.booleanValue()) {
                            logger.log(Logger.WARNING, Globals.getBrokerResources().getKString(
                            BrokerResources.W_PROP_SETTING_TOBE_IGNORED, NEW_TXNLOG_ENABLED_PROP+"=true"));
                        }
                        break;
                    }

View Full Code Here

    }

    public static String getShortBrokerAddress(String brokerID)  {
  BrokerMQAddress ba = null;
  String longAddr = getBrokerAddress(brokerID);
  Logger logger = Globals.getLogger();

  if (longAddr == null)  {
      return (null);
  }

  try  {
      ba = BrokerMQAddress.createAddress(longAddr);
  } catch (Exception e)  {
            BrokerResources  rb = Globals.getBrokerResources();

            logger.log(Logger.WARNING,
    rb.getString(rb.W_JMX_FAILED_TO_OBTAIN_BKR_ADDRESS_FROM_ID, brokerID),
    e);

      return (null);
  }
View Full Code Here

  return (master.equals(cb));
    }

    public static CompositeData getConfigCompositeData(ClusteredBroker cb)
          throws OpenDataException  {
  Logger logger = Globals.getLogger();
  CompositeData cds = null;

  Hashtable bkrInfo = GetClusterHandler.getBrokerClusterInfo(cb, logger);

  String id = null;
View Full Code Here

    }

    // needed for inprocess
    public static void destroy() {
        ssfactory = null;
        Logger logger = null;
        br = null;
    }
View Full Code Here


    // used by other method to get the INFO packet

    public static void sendInfoPacket(int requestType, IMQConnection con, long consumerUID) {
          Logger logger = Globals.getLogger();
          ClusterManager cfg =  Globals.getClusterManager();
          String reason = null;
          int status = Status.OK;

          Packet pkt = new Packet(con.useDirectBuffers());
          pkt.setPacketType(PacketType.INFO);
          pkt.setConsumerID(consumerUID);
          Hashtable replyprops = new Hashtable();       

          Hashtable bodyProperties = null;

          if (cfg == null) {
              status = Status.ERROR;
              reason = "Internal Error: NOT VALID CLUSTER ";
              logger.log(Logger.INFO,reason);
          } else if (requestType == REQUEST_STATUS_INFO) {
               ClusteredBroker cb = cfg.getLocalBroker();
               // OK, set properties
              bodyProperties = getInfo(cb);
              try {
                  if (cb.getState() == BrokerState.SHUTDOWN_STARTED) {
                      long timeout = Globals.getBrokerStateHandler()
                              .getShutdownRemaining();
                      bodyProperties.put("ShutdownMS", new Long(timeout));
                  }
              } catch (BrokerException ex) {
                  logger.logStack(Logger.INFO,"Internal Error: setting timeout ", ex);
              }
          } else if (requestType == REQUEST_CLUSTER_INFO) {
              bodyProperties = getAllInfo();
          } else {
              status = Status.BAD_REQUEST;
              reason = "Internal Error: Bad JMQRequestType set " + requestType;
              logger.log(Logger.INFO,reason);
          }

//XXX - TBD
// should we write out the contents in a less intensive way
// (e.g. use the same format used for properties)
// or just serialize Hashtable (which is whay we are doing now)
//

          String list = null;
          if (cfg != null) {
              Iterator itr = cfg.getKnownBrokers(true);
              Set s = new HashSet();
              // ok get rid of dups
              while (itr.hasNext()) {
                  ClusteredBroker cb = (ClusteredBroker)itr.next();
                  s.add(cb.getBrokerURL().toString());
              }  
                  // OK .. now convert to a string
   
              itr = s.iterator();
   
              while (itr.hasNext()) {
                  if (list == null) {
                      list = itr.next().toString();
                  } else {
                      list += "," + itr.next().toString();
                  }
              }  
              if (list != null) {
                  replyprops.put("JMQBrokerList", list);
              }  
          }

          if (bodyProperties != null) {
              try {
                  ByteArrayOutputStream bos = new ByteArrayOutputStream();
                  ObjectOutputStream oos = new ObjectOutputStream(bos);
                  oos.writeObject(bodyProperties);
                  oos.flush();
                  bos.flush();
                  pkt.setMessageBody(bos.toByteArray());
                  bos.close();
              } catch (Exception ex) {
                   logger.log(Logger.WARNING,"XXX-L10N Internal Error "
                         + " sending back broker data", ex);
              }
          }
          // OK deal with properties, etc
          replyprops.put("JMQRequestType", new Integer(requestType));
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.util.log.Logger

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.