use of dmg.cells.nucleus.CellVersion in project dcache by dCache.
the class PoolInfoRequestHandler method getCellInfoRequest.
private CellData getCellInfoRequest() {
CellData request = new CellData();
CellInfo info = supplier.get();
request.setCreationTime(info.getCreationTime());
request.setDomainName(info.getDomainName());
request.setCellType(info.getCellType());
request.setCellName(info.getCellName());
request.setCellClass(info.getCellClass());
request.setEventQueueSize(info.getEventQueueSize());
request.setExpectedQueueTime(info.getExpectedQueueTime());
request.setLabel("Cell Info");
CellVersion version = info.getCellVersion();
request.setRelease(version.getRelease());
request.setRevision(version.getRevision());
request.setVersion(version.toString());
request.setState(info.getState());
request.setThreadCount(info.getThreadCount());
return request;
}
use of dmg.cells.nucleus.CellVersion in project dcache by dCache.
the class CellInfoMsgHandler method addCellInfo.
/**
* Add some information about a specific cell
*
* @param update the StateUpdate that metrics will be added
* @param thisCellPath the StatePath for metrics for this branch
* @param thisCell the CellInfo for the specific cell
* @param lifetime how long the metrics should last.
*/
private void addCellInfo(StateUpdate update, StatePath thisCellPath, CellInfo thisCell, long lifetime) {
update.appendUpdate(thisCellPath.newChild("class"), new StringStateValue(thisCell.getCellClass(), lifetime));
update.appendUpdate(thisCellPath.newChild("type"), new StringStateValue(thisCell.getCellType(), lifetime));
CellVersion cellVersion = thisCell.getCellVersion();
if (cellVersion != null) {
addVersionInfo(update, thisCellPath, cellVersion, lifetime);
}
CellMessageHandlerSkel.addTimeMetrics(update, thisCellPath.newChild("created"), thisCell.getCreationTime(), lifetime);
update.appendUpdate(thisCellPath.newChild("event-queue-size"), new IntegerStateValue(thisCell.getEventQueueSize(), lifetime));
update.appendUpdate(thisCellPath.newChild("thread-count"), new IntegerStateValue(thisCell.getThreadCount(), lifetime));
}
use of dmg.cells.nucleus.CellVersion in project dcache by dCache.
the class CellInfoMsgHandlerTests method testReceivedCellInfo.
@Test
public void testReceivedCellInfo() {
CellInfo[] info = new CellInfo[1];
String version = "version";
String release = "release";
String cellName = "cell-1";
String cellType = "cell-1-type";
String cellClass = "cell-1-class";
String domainName = "domain-1";
Date creationTime = new Date();
String privateInfo = "cell-1-private";
String shortInfo = "cell-1-short";
int eventQueueSize = 3;
int threadCount = 5;
int state = 2;
CellVersion cellVersion = new CellVersion(version, release);
info[0] = new InitialisableCellInfo(cellName, cellType, cellClass, cellVersion, domainName, creationTime, privateInfo, shortInfo, eventQueueSize, threadCount, state);
info[0].setCellVersion(new CellVersion(version, release));
_handler.process(info, 10);
Queue<StateUpdate> updates = _sum.getQueue();
assertEquals("checking StateUpdateManager's queue size", 1, updates.size());
assertCellInfo(updates.poll(), info[0]);
}
use of dmg.cells.nucleus.CellVersion in project dcache by dCache.
the class CellInfoMsgHandlerTests method assertCellInfo.
/**
* Assert that the supplied StateUpdate object contains fresh values for the expected metrics
* for the given CellInfo object.
*
* @param update
* @param info
*/
private static void assertCellInfo(StateUpdate update, CellInfo info) {
assertEquals("expect number of purges", 0, update.countPurges());
assertEquals("expected number of metric updates", 9, update.count());
StatePath cellPath = StatePath.parsePath("domains").newChild(info.getDomainName()).newChild("cells").newChild(info.getCellName());
assertTrue("Check class metric added", update.hasUpdate(cellPath.newChild("class"), new StringStateValue(info.getCellClass())));
assertTrue("Check type metric added", update.hasUpdate(cellPath.newChild("type"), new StringStateValue(info.getCellType())));
assertTrue("Check event-queue-size metric added", update.hasUpdate(cellPath.newChild("event-queue-size"), new IntegerStateValue(info.getEventQueueSize())));
assertTrue("Check thread-count metric added", update.hasUpdate(cellPath.newChild("thread-count"), new IntegerStateValue(info.getThreadCount())));
// Three metrics under the "created" branch
StatePath createdPath = cellPath.newChild("created");
assertTrue("Check created.unix metric added", update.hasUpdate(createdPath.newChild("unix"), new IntegerStateValue(info.getCreationTime().getTime() / 1000)));
assertTrue("Check created.simple metric added", update.hasUpdate(createdPath.newChild("simple"), new StringStateValue(SIMPLE_DATE_FORMAT.format(info.getCreationTime()))));
assertTrue("Check created.ISO-8601 metric added", update.hasUpdate(createdPath.newChild("ISO-8601"), new StringStateValue(ISO8601_DATE_FORMAT.format(info.getCreationTime()))));
// Two metrics under the "version" branch
StatePath versionPath = cellPath.newChild("version");
CellVersion version = info.getCellVersion();
assertTrue("Check version.revision metric added", update.hasUpdate(versionPath.newChild("revision"), new StringStateValue(version.getRevision())));
assertTrue("Check version.release metric added", update.hasUpdate(versionPath.newChild("release"), new StringStateValue(version.getRelease())));
}
use of dmg.cells.nucleus.CellVersion in project dcache by dCache.
the class LoginManager method starting.
@Override
protected void starting() throws Exception {
if (_args.argc() < 2) {
throw new IllegalArgumentException("USAGE : ... <listenPort> <loginCell>" + " [-maxLogin=<n>|-1]" + " [-keepAlive=<seconds>]" + " [-acceptErrorWait=<msecs>]" + " [args givenToLoginClass]");
}
int listenPort = Integer.parseInt(_args.argv(0));
String loginCell = _args.argv(1);
Args childArgs = new Args(_args.toString().replaceFirst("(^|\\s)-consume=\\S*", "").replaceFirst("(^|\\s)-subscribe=\\S*", ""));
childArgs.shift();
childArgs.shift();
// get the authentication
_authenticator = new CellPath(_args.getOption("authenticator", "pam"));
String maxLogin = _args.getOpt("maxLogin");
if (maxLogin != null) {
try {
_maxLogin = Integer.parseInt(maxLogin);
} catch (NumberFormatException ee) {
/* bad values ignored */
}
}
if (_maxLogin < 0) {
LOGGER.info("Maximum login feature disabled");
} else {
LOGGER.info("Maximum logins set to: {}", _maxLogin);
}
_scheduledExecutor = Executors.newSingleThreadScheduledExecutor(_nucleus);
// keep alive
long keepAlive = TimeUnit.SECONDS.toMillis(_args.getLongOption("keepAlive", 0L));
LOGGER.info("Keep alive set to {} ms", keepAlive);
_keepAlive = new KeepAliveTask();
_keepAlive.schedule(keepAlive);
_loginCellFactory = new LoginCellFactoryBuilder().setName(loginCell).setCellEndpoint(this).setLoginManagerName(getCellName()).setArgs(childArgs).build();
_version = new CellVersion(Version.of(_loginCellFactory));
String topic = _args.getOpt("brokerTopic");
if (topic != null) {
Splitter byComma = Splitter.on(",").omitEmptyStrings();
Splitter byColon = Splitter.on(":").omitEmptyStrings();
_loginBrokerPublisher = new LoginBrokerPublisher();
_loginBrokerPublisher.setExecutor(_scheduledExecutor);
_loginBrokerPublisher.setTopic(topic);
_loginBrokerPublisher.setCellEndpoint(this);
_loginBrokerPublisher.setCellAddress(_nucleus.getThisAddress());
_loginBrokerPublisher.setTags(byComma.splitToList(_args.getOption("brokerTags")));
_loginBrokerPublisher.setProtocolEngine(_loginCellFactory.getName());
_loginBrokerPublisher.setProtocolFamilies(_args.getOption("protocolFamily", ""));
_loginBrokerPublisher.setProtocolVersion(_args.getOption("protocolVersion", "1.0"));
_loginBrokerPublisher.setUpdateTime(_args.getLongOption("brokerUpdateTime"));
_loginBrokerPublisher.setUpdateTimeUnit(TimeUnit.valueOf(_args.getOption("brokerUpdateTimeUnit")));
_loginBrokerPublisher.setUpdateThreshold(_args.getDoubleOption("brokerUpdateOffset"));
_loginBrokerPublisher.setRoot(Strings.emptyToNull(_args.getOption("brokerRoot", _args.getOption("root"))));
_loginBrokerPublisher.setReadPaths(byColon.splitToList(_args.getOption("brokerReadPaths", "/")));
_loginBrokerPublisher.setWritePaths(byColon.splitToList(_args.getOption("brokerWritePaths", "/")));
_loginBrokerPublisher.setAddress(Strings.emptyToNull(_args.getOption("brokerAddress")));
_loginBrokerPublisher.setPort(_args.getIntOption("brokerPort", 0));
addCommandListener(_loginBrokerPublisher);
addCellEventListener(_loginBrokerPublisher);
if (_maxLogin < 0) {
_maxLogin = 100000;
}
} else {
_loginBrokerPublisher = null;
}
addCellEventListener(new LoginEventListener());
_listenThread = new ListenThread(listenPort);
}
Aggregations