use of com.sun.messaging.jmq.jmsserver.resources.BrokerResources in project openmq by eclipse-ee4j.
the class ConsumerUtil method getConsumerInfo.
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));
}
// triggers the broker to load messages if necessary
con.load();
cid = con.getConsumerUID();
if (cid == null) {
throw new BrokerException(rb.getString(rb.X_JMX_CONSUMER_NOT_FOUND, consumerID));
}
cd = getConsumerInfo(cid);
return (cd);
}
use of com.sun.messaging.jmq.jmsserver.resources.BrokerResources in project openmq by eclipse-ee4j.
the class ChangeRecord method prepareRestoreRecords.
/**
* Preparing for restoring change records.
*/
public static List<ChangeRecordInfo> prepareRestoreRecords(String fileName) throws Exception {
Logger logger = Globals.getLogger();
BrokerResources br = Globals.getBrokerResources();
if (DEBUG) {
logger.logToAll(Logger.INFO, "ChangeRecord.prepareRestoreRecords from file " + fileName);
}
FileInputStream fis = null;
DataInputStream dis = null;
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);
}
fis = new FileInputStream(f);
dis = new DataInputStream(fis);
// Version
int curversion = dis.readInt();
// Signature.
String sig = dis.readUTF();
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<>();
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());
cri.setUKey(cr.getUniqueKey());
cri.setDuraAdd(cr.isDuraAdd());
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;
} finally {
if (dis != null) {
try {
dis.close();
} catch (Exception e) {
/* ignore */
}
}
if (fis != null) {
try {
fis.close();
} catch (Exception e) {
/* ignore */
}
}
}
}
use of com.sun.messaging.jmq.jmsserver.resources.BrokerResources in project openmq by eclipse-ee4j.
the class ShareConfigChangeDBManager method throwTableLockedException.
@Override
protected void throwTableLockedException(TableLock lock) throws BrokerException {
BrokerResources br = Globals.getBrokerResources();
String emsg = null;
if (lock.port != 0) {
emsg = br.getKString(br.E_SHARECC_TABLE_LOCKED_BY, lock.host, String.valueOf(lock.port));
throw new BrokerException(emsg, br.E_SHARECC_TABLE_LOCKED_BY, null, Status.CONFLICT);
}
emsg = br.getKString(br.E_SHARECC_TABLE_LOCKED_BY_DBMGR, "imqdbmgr");
throw new BrokerException(emsg, br.E_SHARECC_TABLE_LOCKED_BY_DBMGR, null, Status.CONFLICT);
}
Aggregations