/*
* (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Contributors:
* mcedica
*/
package org.nuxeo.ecm.core.management.probes;
import java.util.HashMap;
import java.util.Map;
import org.nuxeo.ecm.core.management.api.AdministrativeStatus;
import org.nuxeo.ecm.core.management.api.AdministrativeStatusManager;
import org.nuxeo.ecm.core.management.api.Probe;
import org.nuxeo.ecm.core.management.api.ProbeStatus;
import org.nuxeo.runtime.api.Framework;
/**
* Retrieves the administrative status of the server.
*
* @author Mariana Cedica
*/
public class AdministrativeStatusProbe implements Probe {
@Override
public ProbeStatus run() {
AdministrativeStatusManager adm = Framework.getLocalService(AdministrativeStatusManager.class);
AdministrativeStatus status = adm.getNuxeoInstanceStatus();
Map<String, String> infos = new HashMap<String, String>();
infos.put("server", status.getInstanceIdentifier());
infos.put("host", Framework.getProperty("org.nuxeo.runtime.server.host", "localhost"));
infos.put("status", status.getState());
if (!status.isActive()) {
return ProbeStatus.newFailure(infos);
}
return ProbeStatus.newSuccess(infos);
}
}