Package com.sun.messaging.jmq.jmsserver.resources

Examples of com.sun.messaging.jmq.jmsserver.resources.BrokerResources


        Logger logger = Globals.getLogger();
        if (DEBUG) {
            logger.logToAll(Logger.INFO, "ChangeRecord.backup("+fileName+")");
        }

        BrokerResources br = Globals.getBrokerResources();
        int loglevel = (throwEx ? Logger.ERROR:Logger.WARNING);

        try {
            // Make sure that the file does not exist.
            File f = new File(fileName);
            if (!f.createNewFile()) {
                String emsg = br.getKString(br.W_MBUS_CANCEL_BACKUP2, fileName);
                logger.logToAll(loglevel, emsg);
                if (throwEx) {
                    throw new BrokerException(emsg);
                }
                return;
            }

            FileOutputStream fos = new FileOutputStream(f);
            DataOutputStream dos = new DataOutputStream(fos);

            ArrayList<ChangeRecord> recordList = compressRecords(records);

            dos.writeInt(ProtocolGlobals.getCurrentVersion());
            dos.writeUTF(ProtocolGlobals.CFGSRV_BACKUP_PROPERTY); // Signature.

            // Write the RESET record here.
            ChangeRecordInfo cri = makeResetRecord(true);
            byte[] rst = cri.getRecord();
            dos.writeInt(rst.length);
            dos.write(rst, 0, rst.length);
            if (DEBUG) {
                logger.logToAll(Logger.INFO, "ChangeRecord.backupRecords backup record "+cri);
            }

            ChangeRecord cr = null;
            for (int i = 0; i < recordList.size(); i++) {
                cr = recordList.get(i);

                if (! cr.isDiscard()) {
                    byte[] rec = cr.getBytes();

                    dos.writeInt(rec.length);
                    dos.write(rec, 0, rec.length);
                    if (DEBUG) {
                        logger.logToAll(Logger.INFO, "ChangeRecord.backupRecords() backup record "+cr);
                    }
                }
            }
            dos.writeInt(0);
            logger.logToAll(Logger.INFO, br.I_CLUSTER_MB_BACKUP_SUCCESS, fileName);
        }
        catch (Exception e) {
            String emsg = br.getKString(br.W_MBUS_BACKUP_ERROR, e.getMessage());
            logger.logStack((throwEx ? Logger.ERROR:Logger.WARNING), emsg, e);
            if (throwEx) {
                throw new BrokerException(emsg);
            }
        }
View Full Code Here


        Logger logger = Globals.getLogger();
        if (DEBUG) {
            logger.logToAll(Logger.INFO, "ChangeRecord.prepareRestoreRecords from file " + fileName);
        }

    BrokerResources br = Globals.getBrokerResources();

        try {
            // Make sure that the file does exist.
            File f = new File(fileName);
            if (! f.exists()) {
                String emsg = br.getKString(br.W_MBUS_CANCEL_RESTORE1, fileName);
                logger.log(Logger.WARNING, emsg);
                throw new BrokerException(emsg);
            }

            FileInputStream fis = new FileInputStream(f);
            DataInputStream dis = new DataInputStream(fis);

            int curversion = dis.readInt(); // Version
            String sig = dis.readUTF(); // Signature.

            if (! sig.equals(ProtocolGlobals.CFGSRV_BACKUP_PROPERTY)) {
                String emsg = br.getKString(br.W_MBUS_CANCEL_RESTORE2, fileName);
                logger.logToAll(Logger.WARNING, emsg);
                throw new BrokerException(emsg);
            }

            if (curversion < ProtocolGlobals.VERSION_350 ||
                curversion > ProtocolGlobals.getCurrentVersion()) {
                String emsg = br.getKString(br.W_MBUS_CANCEL_RESTORE3,
                                  String.valueOf(curversion),
                                  String.valueOf(ProtocolGlobals.getCurrentVersion()));
                logger.logToAll(Logger.ERROR, emsg);
                throw new BrokerException(emsg);
            }

            ArrayList<ChangeRecordInfo> records = new ArrayList<ChangeRecordInfo>();

            while (true) {
                int recsize = dis.readInt();
                if (recsize == 0)
                    break;

                byte[] rec = new byte[recsize];
                dis.readFully(rec, 0, recsize);

                ChangeRecordInfo cri = new ChangeRecordInfo();
                cri.setRecord(rec);

                ChangeRecord cr = makeChangeRecord(rec);
                cri.setType(cr.getPacketType());

                if (Globals.useSharedConfigRecord()) {
                    String uuid = cr.getUUID();
                    if (uuid == null) {
                        uuid = UUID.randomUUID().toString();
                    }
                    cri.setUUID(uuid);
                }
                records.add(cri);
                if (DEBUG) {
                    logger.logToAll(Logger.INFO,
                        "ChangeRecord.prepareRestoreRecords restore record " + cri);
                }
            }

            dis.close();
            fis.close();

            logger.logToAll(Logger.INFO, br.getKString(br.I_CLUSTER_MB_RESTORE_PROCESS_RECORDS,
                                         String.valueOf(records.size()), fileName));
            return records;

        } catch (Exception e) {
            String emsg = br.getKString(br.W_MBUS_RESTORE_ERROR, fileName, e.getMessage());
            logger.logStack(Logger.ERROR, emsg, e);
            throw e;
        }

    }
View Full Code Here

        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;
        }
View Full Code Here

      type.equals(DestinationType.TOPIC))  {
     
      return;
  }

  BrokerResources rb = Globals.getBrokerResources();
  throw new BrokerException(rb.getString(rb.X_JMX_INVALID_DEST_TYPE_SPEC, type));
    }
View Full Code Here

  for (Iterator i = attrs.iterator(); i.hasNext();) {
      Attribute attr = (Attribute) i.next();
      String name = attr.getName();
     
      if (!checkOneDestAttr(name, validAttrs))  {
          BrokerResources rb = Globals.getBrokerResources();
    String err;

    if (type.equals(DestinationType.QUEUE))  {
              err = rb.getString(rb.X_JMX_INVALID_CREATE_TIME_ATTR_SPEC_QUEUE, name);
    } else  {
              err = rb.getString(rb.X_JMX_INVALID_CREATE_TIME_ATTR_SPEC_TOPIC, name);
    }
    throw new BrokerException(err);
      }
  }
    }
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);

            }
View Full Code Here

      pauseType.equals(DestinationPauseType.CONSUMERS))  {
     
      return;
  }

  BrokerResources rb = Globals.getBrokerResources();

  throw new IllegalArgumentException(rb.getString(rb.X_JMX_INVALID_DEST_PAUSE_TYPE_SPEC, pauseType));
    }
View Full Code Here

    public static CompositeData getTransactionInfo(String transactionID)
        throws BrokerException, OpenDataException  {
  CompositeData cd = null;
  TransactionUID tid = null;
        BrokerResources  rb = Globals.getBrokerResources();

  if (transactionID == null)  {
      throw new
    IllegalArgumentException(rb.getString(rb.X_JMX_NULL_TXN_ID_SPEC));
  }

  long longTid = 0;

  try  {
      longTid = Long.parseLong(transactionID);
  } catch (NumberFormatException e)  {
      throw new
    IllegalArgumentException(rb.getString(rb.X_JMX_INVALID_TXN_ID_SPEC, transactionID));
  }

  tid = new TransactionUID(longTid);

  if (tid == null)  {
      throw new BrokerException(rb.getString(rb.X_JMX_TXN_NOT_FOUND, transactionID));
  }

  cd = getTransactionInfo(tid);

  return (cd);
View Full Code Here

  }

  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

    public static CompositeData getConsumerInfo(String consumerID)
        throws BrokerException, OpenDataException  {
  CompositeData cd = null;
  ConsumerUID tmpcid, cid = null;
        BrokerResources  rb = Globals.getBrokerResources();

  if (consumerID == null)  {
      throw new
    IllegalArgumentException(rb.getString(rb.X_JMX_NULL_CONSUMER_ID_SPEC));
  }

  long longCid = 0;

  try  {
      longCid = Long.parseLong(consumerID);
  } catch (NumberFormatException e)  {
      throw new
    IllegalArgumentException(rb.getString(rb.X_JMX_INVALID_CONSUMER_ID_SPEC, consumerID));
  }

  tmpcid = new ConsumerUID(longCid);

  Consumer con = Consumer.getConsumer(tmpcid);

  if (con == null)  {
      throw new BrokerException(rb.getString(rb.X_JMX_CONSUMER_NOT_FOUND, consumerID));
  }
    con.load(); // triggers the broker to load messages if necessary

  cid = con.getConsumerUID();

  if (cid == null)  {
      throw new BrokerException(rb.getString(rb.X_JMX_CONSUMER_NOT_FOUND, consumerID));
  }

  cd = getConsumerInfo(cid);

  return (cd);
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.resources.BrokerResources

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.