All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.uima.ducc.ws.server.DuccHandlerClassic Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
*/
package org.apache.uima.ducc.ws.server;

import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentSkipListMap;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.uima.ducc.cli.ws.json.MachineFacts;
import org.apache.uima.ducc.cli.ws.json.MachineFactsList;
import org.apache.uima.ducc.common.IDuccEnv;
import org.apache.uima.ducc.common.NodeConfiguration;
import org.apache.uima.ducc.common.boot.DuccDaemonRuntimeProperties;
import org.apache.uima.ducc.common.boot.DuccDaemonRuntimeProperties.DaemonName;
import org.apache.uima.ducc.common.internationalization.Messages;
import org.apache.uima.ducc.common.utils.ComponentHelper;
import org.apache.uima.ducc.common.utils.DuccLogger;
import org.apache.uima.ducc.common.utils.DuccLoggerComponents;
import org.apache.uima.ducc.common.utils.DuccProperties;
import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
import org.apache.uima.ducc.common.utils.DuccSchedulerClasses;
import org.apache.uima.ducc.common.utils.TimeStamp;
import org.apache.uima.ducc.common.utils.id.DuccId;
import org.apache.uima.ducc.transport.Constants;
import org.apache.uima.ducc.transport.event.DbComponentPropertiesHelper;
import org.apache.uima.ducc.transport.event.common.DuccWorkJob;
import org.apache.uima.ducc.transport.event.common.DuccWorkReservation;
import org.apache.uima.ducc.transport.event.common.IDuccPerWorkItemStatistics;
import org.apache.uima.ducc.transport.event.common.IDuccProcess;
import org.apache.uima.ducc.transport.event.common.IDuccReservation;
import org.apache.uima.ducc.transport.event.common.IDuccReservationMap;
import org.apache.uima.ducc.transport.event.common.IDuccUnits.MemoryUnits;
import org.apache.uima.ducc.transport.event.common.IDuccWork;
import org.apache.uima.ducc.transport.event.common.IDuccWorkJob;
import org.apache.uima.ducc.transport.event.common.IRationale;
import org.apache.uima.ducc.ws.DuccDaemonsData;
import org.apache.uima.ducc.ws.DuccData;
import org.apache.uima.ducc.ws.DuccMachinesData;
import org.apache.uima.ducc.ws.Info;
import org.apache.uima.ducc.ws.JobInfo;
import org.apache.uima.ducc.ws.MachineInfo;
import org.apache.uima.ducc.ws.broker.BrokerHelper;
import org.apache.uima.ducc.ws.broker.BrokerHelper.FrameworkAttribute;
import org.apache.uima.ducc.ws.broker.EntityInfo;
import org.apache.uima.ducc.ws.registry.ServiceInterpreter.StartState;
import org.apache.uima.ducc.ws.registry.ServicesRegistry;
import org.apache.uima.ducc.ws.registry.sort.IServiceAdapter;
import org.apache.uima.ducc.ws.registry.sort.ServicesHelper;
import org.apache.uima.ducc.ws.registry.sort.ServicesSortCache;
import org.apache.uima.ducc.ws.server.DuccCookies.DisplayStyle;
import org.apache.uima.ducc.ws.server.IWebMonitor.MonitorType;
import org.apache.uima.ducc.ws.types.NodeId;
import org.apache.uima.ducc.ws.types.UserId;
import org.apache.uima.ducc.ws.utils.FormatHelper.Precision;
import org.eclipse.jetty.server.Request;

public class DuccHandlerClassic extends DuccAbstractHandler {
	
	private static DuccLogger duccLogger = DuccLoggerComponents.getWsLogger(DuccHandlerClassic.class.getName());
	private static Messages messages = Messages.getInstance();
	private static DuccId jobid = null;
	
	public final String classicJobs 				= duccContextClassic+"-jobs-data";
	public final String classicReservations 		= duccContextClassic+"-reservations-data";
	public final String classicServices			 	= duccContextClassic+"-services-data";
	public final String classicSystemClasses	 	= duccContextClassic+"-system-classes-data";
	public final String classicSystemDaemons	 	= duccContextClassic+"-system-daemons-data";
	public final String classicSystemMachines	 	= duccContextClassic+"-system-machines-data";
	public final String classicSystemBroker		 	= duccContextClassic+"-system-broker-data";
	
	public DuccHandlerClassic(DuccWebServer duccWebServer) {
		super.init(duccWebServer);
	}

	public String getFileName() {
		return dir_home+File.separator+dir_resources+File.separator+getDuccWebServer().getClassDefinitionFile();
	}
	
	private void buildJobsListEntry(HttpServletRequest request, StringBuffer sb, DuccId duccId, IDuccWorkJob job, DuccData duccData, long now, ServicesRegistry servicesRegistry) {
		String type="Job";
		String id = normalize(duccId);
		// Terminate
		sb.append("");
		if(terminateEnabled) {
			if(!job.isFinished()) {
				sb.append("");
			}
		}
		sb.append("");
		// Id
		sb.append("");
		sb.append(""+id+"");
		sb.append("");
		// Start
		sb.append("");
		sb.append("");
		sb.append(getTimeStamp(request,job.getDuccId(), job.getStandardInfo().getDateOfSubmission()));
		sb.append("");
		sb.append("");
		// Duration
		sb.append("");
		if(job.isCompleted()) {
			String duration = getDuration(request,job, Precision.Whole);
			String decoratedDuration = decorateDuration(request,job,duration,Precision.Whole);
			sb.append("");
			sb.append(decoratedDuration);
			sb.append("");
		}
		else {
			String duration = getDuration(request,job,now,Precision.Whole);
			String decoratedDuration = decorateDuration(request,job,duration,Precision.Whole);
			sb.append("");
			sb.append(decoratedDuration);
			sb.append("");
			String projection = getProjection(request,job,Precision.Whole);
			sb.append(projection);
		}
		sb.append("");
		// User
		String title = "";
		String submitter = job.getStandardInfo().getSubmitter();
		if(submitter != null) {
			title = "title=\"submitter PID@host: "+submitter+"\" ";
		}
		sb.append("");
		sb.append(job.getStandardInfo().getUser());
		sb.append("");
		// Class
		sb.append("");
		String schedulingClass = stringNormalize(job.getSchedulingInfo().getSchedulingClass(),messages.fetch("default"));
		long debugPortDriver = job.getDebugPortDriver();
		long debugPortProcess = job.getDebugPortProcess();
		title = "debug ports:";
		if(debugPortDriver >= 0) {
			title = title + " driver="+debugPortDriver;
		}
		if(debugPortProcess >= 0) {
			title = title + " process="+debugPortProcess;
		}
		switch(DuccCookies.getDisplayStyle(request)) {
		case Textual:
		default:
			sb.append(schedulingClass);
			if((debugPortDriver >= 0) || (debugPortProcess >= 0)) {
				sb.append("
"); if(job.isCompleted()) { sb.append(""); } else { sb.append(""); } sb.append("
DEBUG
"); sb.append("
"); } break; case Visual: // Below String key = "bug"; String bugFile = DuccWebServerHelper.getImageFileName(key); sb.append(schedulingClass); if((debugPortDriver >= 0) || (debugPortProcess >= 0)) { sb.append("
"); if(job.isCompleted()) { sb.append(""); } else { sb.append(""); } if(bugFile != null) { sb.append("
"); } sb.append("
"); } break; } sb.append(""); // State sb.append(""); if(duccData.isLive(duccId)) { if(job.isOperational()) { sb.append(""); } else { sb.append(""); } } else { sb.append(""); } sb.append(job.getStateObject().toString()); if(duccData.isLive(duccId)) { sb.append(""); } sb.append(""); // Reason String reason = getReason(job, MonitorType.Job).toString(); sb.append(""); sb.append(reason); sb.append(""); // Services sb.append(""); sb.append(evaluateServices(job,servicesRegistry)); sb.append(""); // Processes sb.append(""); if(duccData.isLive(duccId)) { sb.append(job.getProcessMap().getAliveProcessCount()); } else { sb.append("0"); } sb.append(""); // Initialize Failures sb.append(""); long initFails = job.getProcessInitFailureCount(); if(initFails > 0) { if(job.getSchedulingInfo().getLongSharesMax() < 0) { DisplayStyle style = DuccCookies.getDisplayStyle(request); String key = "cap.small"; String capFile = DuccWebServerHelper.getImageFileName(key); switch(style) { case Visual: if(capFile == null) { style = DisplayStyle.Textual; } break; } switch(style) { case Textual: default: sb.append(buildInitializeFailuresLink(job)); sb.append(""); sb.append(""); sb.append(""); sb.append("capped"); sb.append(""); sb.append(""); sb.append(""); sb.append("
"); break; case Visual: sb.append(""); sb.append(""); sb.append(""); sb.append("
"); sb.append(buildInitializeFailuresLink(job)); break; } } else { sb.append(buildInitializeFailuresLink(job)); } } else { sb.append(""+initFails); } sb.append(""); // Runtime Failures sb.append(""); sb.append(buildRuntimeFailuresLink(job)); sb.append(""); // Pgin sb.append(""); long pgin = job.getPgInCount(); sb.append(""+pgin); sb.append(""); // Swap DecimalFormat formatter = new DecimalFormat("###0.0"); sb.append(""); double swap = job.getSwapUsageGb(); if(job.isCompleted()) { swap = job.getSwapUsageGbMax(); } String displaySwapMax = formatter.format(swap); sb.append(displaySwapMax); sb.append(""); // Size sb.append(""); String size = job.getSchedulingInfo().getShareMemorySize(); MemoryUnits units = job.getSchedulingInfo().getShareMemoryUnits(); sb.append(getProcessMemorySize(duccId,type,size,units)); sb.append(""); // Total sb.append(""); sb.append(job.getSchedulingInfo().getWorkItemsTotal()); sb.append(""); // Done sb.append(""); IDuccPerWorkItemStatistics perWorkItemStatistics = job.getSchedulingInfo().getPerWorkItemStatistics(); String done = job.getSchedulingInfo().getWorkItemsCompleted(); if (perWorkItemStatistics != null) { double max = Math.round(perWorkItemStatistics.getMax()/100.0)/10.0; double min = Math.round(perWorkItemStatistics.getMin()/100.0)/10.0; double avg = Math.round(perWorkItemStatistics.getMean()/100.0)/10.0; double dev = Math.round(perWorkItemStatistics.getStandardDeviation()/100.0)/10.0; done = ""+done+""; } sb.append(done); sb.append(""); // Error sb.append(""); sb.append(buildErrorLink(job)); sb.append(""); // Dispatch sb.append(""); String d0 = ""; String d1 = "0"; String d2 = ""; if(duccData.isLive(duccId)) { int dispatch = 0; int unassigned = job.getSchedulingInfo().getCasQueuedMap().size(); try { dispatch = Integer.parseInt(job.getSchedulingInfo().getWorkItemsDispatched())-unassigned; } catch(Exception e) { } if(dispatch < 0) { d0 = ""; //d1 = "0"; } else { d1 = ""+dispatch; } } sb.append(d0); sb.append(d1); sb.append(d2); sb.append(""); // Retry sb.append(""); sb.append(job.getSchedulingInfo().getWorkItemsRetry()); sb.append(""); // Preempt sb.append(""); sb.append(job.getSchedulingInfo().getWorkItemsPreempt()); sb.append(""); // Description sb.append(""); String description = stringNormalize(job.getStandardInfo().getDescription(),messages.fetch("none")); switch(DuccCookies.getDescriptionStyle(request)) { case Long: default: sb.append(""); sb.append(description); sb.append(""); break; case Short: String shortDescription = getShortDescription(description); if(shortDescription == null) { sb.append(""); sb.append(description); sb.append(""); } else { sb.append(""); sb.append(shortDescription); sb.append(""); } break; } sb.append(""); sb.append(""); } private void handleServletClassicJobs(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { String methodName = "handleServletClassicJobs"; duccLogger.trace(methodName, jobid, messages.fetch("enter")); StringBuffer sb = new StringBuffer(); ServicesRegistry servicesRegistry = ServicesRegistry.getInstance(); long now = System.currentTimeMillis(); int maxRecords = getJobsMax(request); ArrayList users = getJobsUsers(request); DuccData duccData = DuccData.getInstance(); ConcurrentSkipListMap sortedJobs = duccData.getSortedJobs(); if(sortedJobs.size()> 0) { Iterator> iterator = sortedJobs.entrySet().iterator(); int counter = 0; while(iterator.hasNext()) { JobInfo jobInfo = iterator.next().getValue(); DuccWorkJob job = jobInfo.getJob(); boolean list = DuccWebUtil.isListable(request, users, maxRecords, counter, job); if(list) { counter++; sb.append(trGet(counter)); buildJobsListEntry(request, sb, job.getDuccId(), job, duccData, now, servicesRegistry); } } } else { sb.append(""); sb.append(""); if(DuccData.getInstance().isPublished()) { sb.append(messages.fetch("no jobs")); } else { sb.append(messages.fetch("no data")); } sb.append(""); sb.append(""); } duccLogger.debug(methodName, jobid, sb); response.getWriter().println(sb); duccLogger.trace(methodName, jobid, messages.fetch("exit")); } private void buildReservationsListEntry(HttpServletRequest request, StringBuffer sb, DuccId duccId, IDuccWork duccwork, DuccData duccData, long now) { String type="Reservation"; String id = normalize(duccId); String reservationType = "Unmanaged"; if(duccwork instanceof DuccWorkJob) { reservationType = "Managed"; } sb.append(""); if(terminateEnabled) { if(!duccwork.isCompleted()) { String disabled = getDisabledWithHover(request,duccwork); String user = duccwork.getStandardInfo().getUser(); if(user != null) { DuccPropertiesResolver dpr = DuccPropertiesResolver.getInstance(); String jdHostUser = dpr.getCachedProperty(DuccPropertiesResolver.ducc_jd_host_user); // We presume that user is sufficient to identify JD shares if(user.equals(jdHostUser)) { disabled = "disabled=\"disabled\""; } } if(duccwork instanceof DuccWorkReservation) { sb.append(""); } else if(duccwork instanceof DuccWorkJob) { sb.append(""); } else { //huh? } } } sb.append(""); // Id if(reservationType.equals("Managed")) { sb.append(""); sb.append(""+id+""); sb.append(""); } else { sb.append(""); sb.append(id); sb.append(""); } // Start sb.append(""); sb.append(""); sb.append(getTimeStamp(request,duccwork.getDuccId(),duccwork.getStandardInfo().getDateOfSubmission())); sb.append(""); sb.append(""); // Duration sb.append(""); if(duccwork instanceof DuccWorkReservation) { DuccWorkReservation reservation = (DuccWorkReservation) duccwork; String duration; String decoratedDuration; switch(reservation.getReservationState()) { case Completed: sb.append(""); duration = getDuration(request,reservation,Precision.Whole); decoratedDuration = decorateDuration(request,reservation, duration); sb.append(decoratedDuration); sb.append(""); break; default: sb.append(""); duration = getDuration(request,reservation,now,Precision.Whole); decoratedDuration = decorateDuration(request,reservation, duration); sb.append(decoratedDuration); sb.append(""); break; } } else if(duccwork instanceof DuccWorkJob) { DuccWorkJob job = (DuccWorkJob) duccwork; switch(job.getJobState()) { case Completed: sb.append(""); String duration = getDuration(request,job,Precision.Whole); String decoratedDuration = decorateDuration(request,job,duration,Precision.Whole); sb.append(decoratedDuration); sb.append(""); break; default: sb.append(""); duration = getDuration(request,job,now,Precision.Whole); decoratedDuration = decorateDuration(request,job,duration,Precision.Whole); sb.append(decoratedDuration); sb.append(""); break; } } sb.append(""); // User String title = ""; String submitter = duccwork.getStandardInfo().getSubmitter(); if(submitter != null) { title = "title=\"submitter PID@host: "+submitter+"\""; } sb.append(""); UserId userId = new UserId(duccwork.getStandardInfo().getUser()); sb.append(userId.toString()); sb.append(""); // Class sb.append(""); sb.append(stringNormalize(duccwork.getSchedulingInfo().getSchedulingClass(),messages.fetch("default"))); sb.append(""); // Type sb.append(""); sb.append(reservationType); sb.append(""); // State sb.append(""); if(duccData.isLive(duccId)) { if(duccwork.isOperational()) { sb.append(""); } else { sb.append(""); } } else { sb.append(""); } sb.append(duccwork.getStateObject().toString()); if(duccData.isLive(duccId)) { sb.append(""); } sb.append(""); // Reason if(duccwork instanceof DuccWorkReservation) { DuccWorkReservation reservation = (DuccWorkReservation) duccwork; sb.append(""); switch(reservation.getReservationState()) { case WaitingForResources: String rmReason = reservation.getRmReason(); if(rmReason != null) { sb.append(""); sb.append(rmReason); sb.append(""); } break; default: switch(reservation.getCompletionType()) { case Undefined: break; case CanceledByUser: case CanceledByAdmin: try { String cancelUser = duccwork.getStandardInfo().getCancelUser(); if(cancelUser != null) { sb.append(""); sb.append(duccwork.getCompletionTypeObject().toString()); sb.append(""); } else { IRationale rationale = reservation.getCompletionRationale(); if(rationale != null) { sb.append(""); sb.append(duccwork.getCompletionTypeObject().toString()); sb.append(""); } else { sb.append(duccwork.getCompletionTypeObject().toString()); } } } catch(Exception e) { IRationale rationale = reservation.getCompletionRationale(); if(rationale != null) { sb.append(""); sb.append(duccwork.getCompletionTypeObject().toString()); sb.append(""); } else { sb.append(duccwork.getCompletionTypeObject().toString()); } } break; default: IRationale rationale = reservation.getCompletionRationale(); if(rationale != null) { sb.append(""); sb.append(duccwork.getCompletionTypeObject().toString()); sb.append(""); } else { sb.append(duccwork.getCompletionTypeObject().toString()); } break; } break; } sb.append(""); } else if(duccwork instanceof DuccWorkJob) { DuccWorkJob job = (DuccWorkJob) duccwork; String reason = getReason(job, MonitorType.ManagedReservation).toString(); sb.append(""); sb.append(reason); sb.append(""); } // Allocation /* sb.append(""); sb.append(duccwork.getSchedulingInfo().getInstancesCount()); sb.append(""); */ // User Processes sb.append(""); TreeMap nodeMap = new TreeMap(); if(duccwork instanceof DuccWorkReservation) { DuccWorkReservation reservation = (DuccWorkReservation) duccwork; if(!reservation.getReservationMap().isEmpty()) { IDuccReservationMap map = reservation.getReservationMap(); for (DuccId key : map.keySet()) { IDuccReservation value = reservation.getReservationMap().get(key); String node = value.getNodeIdentity().getName(); if(!nodeMap.containsKey(node)) { nodeMap.put(node,new Integer(0)); } Integer count = nodeMap.get(node); count++; nodeMap.put(node,count); } } boolean qualify = false; if(!nodeMap.isEmpty()) { if(nodeMap.keySet().size() > 1) { qualify = true; } } ArrayList qualifiedPids = new ArrayList(); if(duccwork.isOperational()) { DuccMachinesData machinesData = DuccMachinesData.getInstance(); for (String node: nodeMap.keySet()) { NodeId nodeId = new NodeId(node); List nodePids = machinesData.getPids(nodeId, userId); for( String pid : nodePids ) { if(qualify) { qualifiedPids.add(node+":"+pid); } else { qualifiedPids.add(pid); } } } } if(qualifiedPids.size() > 0) { String list = ""; for( String entry : qualifiedPids ) { list += entry+" "; } sb.append(""); sb.append(""+qualifiedPids.size()); sb.append(""); } else { sb.append(""+qualifiedPids.size()); } } else { DuccWorkJob job = (DuccWorkJob) duccwork; if(job.isOperational()) { sb.append(duccwork.getSchedulingInfo().getInstancesCount()); } else { sb.append("0"); } Iterator iterator = job.getProcessMap().keySet().iterator(); while(iterator.hasNext()) { DuccId processId = iterator.next(); IDuccProcess process = job.getProcessMap().get(processId); String node = process.getNodeIdentity().getName(); nodeMap.put(node, 1); } } sb.append(""); // Size sb.append(""); String size = duccwork.getSchedulingInfo().getShareMemorySize(); MemoryUnits units = duccwork.getSchedulingInfo().getShareMemoryUnits(); sb.append(getProcessMemorySize(duccId,type,size,units)); sb.append(""); // Host Names sb.append(""); if(!nodeMap.isEmpty()) { boolean useList = false; if(nodeMap.size() > 1) { useList = true; } if(useList) { sb.append(""); } } sb.append(""); // Description sb.append(""); String description = stringNormalize(duccwork.getStandardInfo().getDescription(),messages.fetch("none")); switch(DuccCookies.getDescriptionStyle(request)) { case Long: default: sb.append(""); sb.append(description); sb.append(""); break; case Short: String shortDescription = getShortDescription(description); if(shortDescription == null) { sb.append(""); sb.append(description); sb.append(""); } else { sb.append(""); sb.append(shortDescription); sb.append(""); } break; } sb.append(""); sb.append(""); } private void handleServletClassicReservations(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { String methodName = "handleServletClassicReservations"; duccLogger.trace(methodName, jobid, messages.fetch("enter")); StringBuffer sb = new StringBuffer(); int maxRecords = getReservationsMax(request); DuccData duccData = DuccData.getInstance(); ConcurrentSkipListMap sortedCombinedReservations = duccData.getSortedCombinedReservations(); ArrayList users = getReservationsUsers(request); long now = System.currentTimeMillis(); if((sortedCombinedReservations.size() > 0)) { int counter = 0; Iterator> iR = sortedCombinedReservations.entrySet().iterator(); while(iR.hasNext()) { Info info = iR.next().getValue(); IDuccWork dw = info.getDuccWork(); boolean list = DuccWebUtil.isListable(request, users, maxRecords, counter, dw); if(list) { counter++; if(dw instanceof DuccWorkReservation) { DuccWorkReservation reservation = (DuccWorkReservation) dw; sb.append(trGet(counter)); buildReservationsListEntry(request, sb, reservation.getDuccId(), reservation, duccData, now); } else if(dw instanceof DuccWorkJob) { DuccWorkJob job = (DuccWorkJob) dw; sb.append(trGet(counter)); buildReservationsListEntry(request, sb, job.getDuccId(), job, duccData, now); } else { // huh? } } } } else { sb.append(""); sb.append(""); if(DuccData.getInstance().isPublished()) { sb.append(messages.fetch("no reservations")); } else { sb.append(messages.fetch("no data")); } sb.append(""); sb.append(""); } duccLogger.debug(methodName, jobid, sb); response.getWriter().println(sb); duccLogger.trace(methodName, jobid, messages.fetch("exit")); } private static DecimalFormat formatter = new DecimalFormat("##0.0"); private void handleServletClassicServices(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { String methodName = "handleServletClassicServices"; duccLogger.trace(methodName, jobid, messages.fetch("enter")); StringBuffer sb = new StringBuffer(); ServicesSortCache servicesSortCache = ServicesSortCache.getInstance(); Collection servicesSortedCollection = servicesSortCache.getSortedCollection(); if(!servicesSortedCollection.isEmpty()) { int maxRecords = getServicesMax(request); ArrayList users = getServicesUsers(request); int counter = 0; for(IServiceAdapter service : servicesSortedCollection) { boolean list = DuccWebUtil.isListable(request, users, maxRecords, counter, service); if(!list) { continue; } counter++; // Row Begin sb.append(""); int sid = service.getId(); String user = service.getUser(); long deployments = service.getDeployments(); long instances = service.getInstances(); // Enable sb.append(""); if(service.isRegistered()) { if(buttonsEnabled) { if(service.isDisabled()) { sb.append(""); } } } sb.append(""); // Stop sb.append(""); if(service.isRegistered()) { if(buttonsEnabled) { if(service.isPingOnly()) { if(service.isPingActive()) { sb.append(""); } } else { if(deployments != 0) { sb.append(""); } } } } sb.append(""); // Id String name = service.getName(); sb.append(""); String id = ""+sid+""; sb.append(""+id); sb.append(""); // Name sb.append(""); sb.append(name); sb.append(""); // State sb.append(""); String state = service.getState(); boolean alert = service.isAlert(); boolean available = service.isStateAvailable(); if(alert) { state += "+Alert"; } String style = "class=\"health_black\";"; if(alert) { style = "class=\"health_red\""; } else if(available) { style = "class=\"health_green\""; } String stateHover = ServicesHelper.getInstance().getStateHover(service); if(stateHover.length() > 0) { stateHover = "title="+"\""+stateHover+"\""; } sb.append(""); sb.append(state); sb.append(""); sb.append(""); // Last Use sb.append(""); long lastUse = service.getLastUse(); if(lastUse > 0) { sb.append(getTimeStamp(request, jobid, ""+lastUse)); } sb.append(""); // Instances sb.append(""); sb.append(instances); sb.append(""); // Deployments sb.append(""); sb.append(deployments); sb.append(""); // Start-State StartState startState = service.getStartState(); sb.append(""); sb.append(""); sb.append(startState.name()); if(service.isDisabled()) { sb.append("
"); String health = "class=\"health_red\""; String reason = "title=\""+service.getDisableReason()+"\""; sb.append(""); sb.append("Disabled"); sb.append(""); } sb.append("
"); sb.append(""); // User sb.append(""); sb.append(user); sb.append(""); // Share Class (or Type) sb.append(""); if(service.isPingOnly()) { String shareClass = service.getShareClass(); sb.append(""); String shareType = "ping-only"; sb.append(""); sb.append(shareType); } else { String shareClass = service.getShareClass(); sb.append(shareClass); } sb.append(""); // PgIn sb.append(""); long pgIn = service.getPgIn(); sb.append(pgIn); sb.append(""); // Swap sb.append(""); double rawSwap = service.getSwap(); rawSwap = rawSwap/Constants.GB; String swap = formatter.format(rawSwap); double rawSwapMax = service.getSwapMax(); rawSwapMax = rawSwapMax/Constants.GB; String swapMax = formatter.format(rawSwap); sb.append(""); sb.append(swap); sb.append(""); sb.append(""); // Size sb.append(""); long size = service.getSize(); if(size < 0) { size = 0; } sb.append(size); sb.append(""); // Jobs sb.append(""); ArrayList dependentJobs = service.getDependentJobs(); int countDependentJobs = dependentJobs.size(); String titleJobs = ""; if(countDependentJobs > 0) { StringBuffer idList = new StringBuffer(); for(String duccId : dependentJobs) { if(idList.length() > 0) { idList.append(","); } idList.append(duccId); } titleJobs = "dependent Job Id list: "+idList; } String jobs = ""+countDependentJobs+""; sb.append(jobs); sb.append(""); // Services sb.append(""); ArrayList dependentServices = service.getDependentServices(); int countDependentServices = dependentServices.size(); String titleServices = ""; if(countDependentServices > 0) { StringBuffer idList = new StringBuffer(); for(String duccId : dependentServices) { if(idList.length() > 0) { idList.append(","); } idList.append(duccId); } titleServices = "dependent Service Name list: "+idList; } String services = ""+countDependentServices+""; sb.append(services); sb.append(""); // Reservations sb.append(""); ArrayList dependentReservations = service.getDependentReservations(); int countDependentReservations = dependentReservations.size(); String titleReservations = ""; if(countDependentReservations > 0) { StringBuffer idList = new StringBuffer(); for(String duccId : dependentReservations) { if(idList.length() > 0) { idList.append(","); } idList.append(duccId); } titleReservations = "dependent Reservation Id list: "+idList; } String reservations = ""+countDependentReservations+""; sb.append(reservations); sb.append(""); // Description sb.append(""); String description = service.getDescription(); sb.append(description); sb.append(""); // Row End sb.append(""); } } else { sb.append(""); sb.append(""); if(DuccData.getInstance().isPublished()) { sb.append(messages.fetch("no services")); } else { sb.append(messages.fetch("no data")); } sb.append(""); sb.append(""); } duccLogger.debug(methodName, jobid, sb); response.getWriter().println(sb); duccLogger.trace(methodName, jobid, messages.fetch("exit")); } private void handleServletClassicSystemClasses(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws Exception { String methodName = "handleServletClassicSystemClasses"; duccLogger.trace(methodName, jobid, messages.fetch("enter")); StringBuffer sb = new StringBuffer(); DuccSchedulerClasses schedulerClasses = DuccSchedulerClasses.getInstance(); Map clmap = schedulerClasses.getClasses(); if ( clmap != null ) { DuccProperties[] class_set = clmap.values().toArray(new DuccProperties[clmap.size()]); Arrays.sort(class_set, new NodeConfiguration.ClassSorter()); int i = 0; for ( DuccProperties cl : class_set) { String class_name = cl.getProperty("name"); sb.append(trGet(i+1)); sb.append(""); sb.append(class_name); sb.append(""); sb.append(""); String policy = cl.getProperty("policy"); sb.append(policy); sb.append(""); sb.append(""); sb.append(cl.getStringProperty("weight", "-")); sb.append(""); sb.append(""); sb.append(cl.getProperty("priority")); sb.append(""); // cap is either absolute or proportional. if proprotional, it ends with '%'. It's always // either-or so at least one of these columns will have N/A String val = cl.getProperty("cap"); if( (val == null) || val.equals("0") || (Integer.parseInt(val) == Integer.MAX_VALUE) ) { sb.append(""); sb.append("-"); sb.append(""); sb.append(""); sb.append("-"); sb.append(""); } else if ( val.endsWith("%") ) { sb.append(""); sb.append(val); sb.append(""); sb.append(""); sb.append("-"); sb.append(""); } else { sb.append(""); sb.append("-"); sb.append(""); sb.append(""); sb.append(val); sb.append(""); } if ( policy.equals("FAIR_SHARE") ) { sb.append(""); val = cl.getStringProperty("initialization-cap", System.getProperty("ducc.rm.initialization.cap")); if ( val == null ) { val = "2"; } sb.append(val); sb.append(""); sb.append(""); String bval = cl.getStringProperty("expand-by-doubling", "-"); sb.append(bval); sb.append(""); sb.append(""); val = cl.getStringProperty("use-prediction", System.getProperty("ducc.rm.prediction")); if ( val == null ) { val = "-"; } sb.append(val); sb.append(""); sb.append(""); val = cl.getStringProperty("prediction-fudge", System.getProperty("ducc.rm.prediction.fudge")); if ( val == null ) { val = "-"; } sb.append(val); sb.append(""); } else { sb.append("-"); // not applicable for non-fair-share sb.append("-"); sb.append("-"); sb.append("-"); } // max for reserve in in machines. For fixed is in processes. No max on fair-share. So slightly // ugly code here. sb.append(""); if ( policy.equals("RESERVE") ) { val = cl.getProperty("max-machines"); if( val == null || val.equals("0")) { val = "-"; } } else if ( policy.equals("FIXED_SHARE") ) { val = cl.getProperty("max-processes"); if( val == null || val.equals("0")) { val = "-"; } } else { val = "-"; } val = cl.getProperty("max-shares"); if( val == null || val.equals("0")) { val = "-"; } sb.append(val); sb.append(""); sb.append(""); val = cl.getProperty("nodepool"); sb.append(val); sb.append(""); // Debug sb.append(""); val = "-"; if(schedulerClasses.isPreemptable(class_name)) { String v1 = cl.getStringProperty("debug", ""); if(!v1.equals("")) { val = v1; } } sb.append(val); sb.append(""); sb.append(""); } } duccLogger.debug(methodName, jobid, sb); response.getWriter().println(sb); duccLogger.trace(methodName, jobid, messages.fetch("exit")); } private void handleServletClassicSystemDaemons(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { String methodName = "handleServletClassicSystemDaemons"; duccLogger.trace(methodName, jobid, messages.fetch("enter")); StringBuffer sb = new StringBuffer(); DuccDaemonsData duccDaemonsData = DuccDaemonsData.getInstance(); int counter = 0; daemons: for(DaemonName daemonName : DuccDaemonRuntimeProperties.daemonNames) { String status = ""; String heartbeat = "*"; String heartmax = "*"; Properties properties = DuccDaemonRuntimeProperties.getInstance().get(daemonName); if(!db) { switch(daemonName) { case DbManager: continue daemons; default: break; } } switch(daemonName) { case Webserver: status = DuccHandlerUtils.up(); break; default: status = DuccHandlerUtils.unknown(); if(daemonName.equals(DaemonName.Orchestrator)) { if(ComponentHelper.isLocked(IDuccEnv.DUCC_STATE_DIR,"orchestrator")) { String filename = ComponentHelper.getLockFileName(IDuccEnv.DUCC_STATE_DIR,"orchestrator"); String hover = "title=\""+ComponentHelper.getLockFileNameWithPath(IDuccEnv.DUCC_STATE_DIR,"orchestrator")+"\""; String fileNameWithHover = ""+filename+""; status += ", "+DuccHandlerUtils.warn("warning: ")+fileNameWithHover+" found."; } } heartbeat = DuccDaemonsData.getInstance().getHeartbeat(daemonName); long timeout = getMillisMIA(daemonName)/1000; if(timeout > 0) { try { long overtime = timeout - Long.parseLong(heartbeat); if(overtime < 0) { status = DuccHandlerUtils.down(); if(daemonName.equals(DaemonName.Orchestrator)) { if(ComponentHelper.isLocked(IDuccEnv.DUCC_STATE_DIR,"orchestrator")) { String filename = ComponentHelper.getLockFileName(IDuccEnv.DUCC_STATE_DIR,"orchestrator"); String hover = "title=\""+ComponentHelper.getLockFileNameWithPath(IDuccEnv.DUCC_STATE_DIR,"orchestrator")+"\""; String fileNameWithHover = ""+filename+""; status += ", "+DuccHandlerUtils.warn("warning: ")+fileNameWithHover+" found."; } } } else { status = DuccHandlerUtils.up(); if(daemonName.equals(DaemonName.DbManager)) { properties = DuccDaemonsData.getInstance().getProperties(daemonName); if(properties != null) { DbComponentPropertiesHelper dcph = new DbComponentPropertiesHelper(properties); if(dcph.isDisabled()) { status = DuccHandlerUtils.disabled(); } } } if(daemonName.equals(DaemonName.Orchestrator)) { int jdCount = DuccData.getInstance().getLive().getJobDriverNodeCount(); if(jdCount == 0) { status = DuccHandlerUtils.up_provisional(", pending JD allocation"); } } } } catch(Throwable t) { } } heartmax = DuccDaemonsData.getInstance().getMaxHeartbeat(daemonName); break; } // Status sb.append(trGet(counter)); sb.append(""); sb.append(status); sb.append(""); // Daemon Name sb.append(""); sb.append(getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyDaemonName,daemonName.toString())); sb.append(""); // Boot Time sb.append(""); sb.append(getTimeStamp(DuccCookies.getDateStyle(request),getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyBootTime,""))); sb.append(""); // Host IP sb.append(""); sb.append(getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyNodeIpAddress,"")); sb.append(""); // Host Name sb.append(""); sb.append(getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyNodeName,"")); sb.append(""); // PID sb.append(""); sb.append(getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyPid,"")); sb.append(""); // Publication Size (last) sb.append(""); Long pubSize = duccDaemonsData.getEventSize(daemonName); sb.append(""+pubSize); sb.append(""); // Publication Size (max) sb.append(""); Long pubSizeMax = duccDaemonsData.getEventSizeMax(daemonName); sb.append(""+pubSizeMax); sb.append(""); // Heartbeat (last) sb.append(""); sb.append(heartbeat); sb.append(""); // Heartbeat (max) sb.append(""); sb.append(heartmax); sb.append(""); // Heartbeat (max) TOD sb.append(""); String heartmaxTOD = TimeStamp.simpleFormat(DuccDaemonsData.getInstance().getMaxHeartbeatTOD(daemonName)); try { heartmaxTOD = getTimeStamp(DuccCookies.getDateStyle(request),heartmaxTOD); } catch(Exception e) { } sb.append(heartmaxTOD); sb.append(""); // JConsole URL sb.append(""); String jmxUrl = getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyJmxUrl,""); if(jmxUrl != null) { sb.append(buildjConsoleLink(jmxUrl)); } sb.append(""); // sb.append(""); counter++; } // String cookie = DuccCookies.getCookie(request,DuccCookies.cookieAgents); if(cookie.equals(DuccCookies.valueAgentsShow)) { duccLogger.trace(methodName, jobid, "== show: "+cookie); ConcurrentSkipListMap machines = DuccMachinesData.getInstance().getMachines(); Iterator iterator = machines.keySet().iterator(); while(iterator.hasNext()) { String key = iterator.next(); MachineInfo machineInfo = machines.get(key); Properties properties = DuccDaemonRuntimeProperties.getInstance().getAgent(machineInfo.getName()); sb.append(trGet(counter)); // Status StringBuffer status = new StringBuffer(); String machineStatus = machineInfo.getStatus(); if(machineStatus.equals("down")) { //status.append(""); status.append(DuccHandlerUtils.down()); //status.append(""); } else if(machineStatus.equals("up")) { //status.append(""); status.append(DuccHandlerUtils.up()); //status.append(""); } else { status.append(DuccHandlerUtils.unknown()); } sb.append(""); sb.append(status); sb.append(""); sb.append(""); // Daemon Name String daemonName = "Agent"; sb.append(""); sb.append(daemonName); sb.append(""); // Boot Time String bootTime = getTimeStamp(DuccCookies.getDateStyle(request),getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyBootTime,"")); sb.append(""); sb.append(bootTime); sb.append(""); // Host IP String hostIP = getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyNodeIpAddress,""); sb.append(""); sb.append(hostIP); sb.append(""); // Host Name String hostName = machineInfo.getName(); sb.append(""); sb.append(hostName); sb.append(""); // PID String pid = getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyPid,""); sb.append(""); sb.append(pid); sb.append(""); // Publication Size (last) String publicationSizeLast = machineInfo.getPublicationSizeLast(); sb.append(""); sb.append(publicationSizeLast); sb.append(""); // Publication Size (max) String publicationSizeMax = machineInfo.getPublicationSizeMax(); sb.append(""); sb.append(publicationSizeMax); sb.append(""); // Heartbeat (last) String heartbeatLast = machineInfo.getHeartbeatLast(); sb.append(""); sb.append(heartbeatLast); sb.append(""); // Heartbeat (max) long heartbeatMax = machineInfo.getHeartbeatMax(); sb.append(""); if(heartbeatMax > 0) { sb.append(heartbeatMax); } sb.append(""); // Heartbeat (max) TOD String fmtHeartbeatMaxTOD = ""; long heartbeatMaxTOD = machineInfo.getHeartbeatMaxTOD(); if(heartbeatMaxTOD > 0) { fmtHeartbeatMaxTOD = TimeStamp.simpleFormat(""+heartbeatMaxTOD); try { fmtHeartbeatMaxTOD = getTimeStamp(DuccCookies.getDateStyle(request),fmtHeartbeatMaxTOD); } catch(Exception e) { } } sb.append(""); sb.append(fmtHeartbeatMaxTOD); sb.append(""); // JConsole URL sb.append(""); String jmxUrl = getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyJmxUrl,""); if(jmxUrl != null) { sb.append(buildjConsoleLink(jmxUrl)); } sb.append(""); // sb.append(""); counter++; } } else { duccLogger.trace(methodName, jobid, "!= show: "+cookie); } // duccLogger.debug(methodName, jobid, sb); response.getWriter().println(sb); duccLogger.trace(methodName, jobid, messages.fetch("exit")); } private void handleServletClassicSystemMachines(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { String methodName = "handleServletClassicSystemMachines"; duccLogger.trace(methodName, jobid, messages.fetch("enter")); int counter = 0; int sumMemoryEffective = 0; int sumMemoryTotal = 0; int sumSwapInuse = 0; /* int sumSwapDelta = 0; */ int sumSwapFree = 0; int sumAliens = 0; int sumSharesTotal = 0; int sumSharesInuse = 0; ListIterator listIterator; StringBuffer row; StringBuffer data = new StringBuffer(); DuccMachinesData instance = DuccMachinesData.getInstance(); MachineFactsList factsList = instance.getMachineFactsList(); if(factsList.size() > 0) { // Total listIterator = factsList.listIterator(); while(listIterator.hasNext()) { MachineFacts facts = listIterator.next(); try { sumMemoryEffective += Integer.parseInt(facts.memoryEffective); sumMemoryTotal += Integer.parseInt(facts.memoryTotal); sumSwapInuse += Integer.parseInt(facts.swapInuse); /* sumSwapDelta += Integer.parseInt(facts.swapDelta); */ sumSwapFree += Integer.parseInt(facts.swapFree); sumAliens += facts.aliens.size(); sumSharesTotal += Integer.parseInt(facts.sharesTotal); sumSharesInuse += Integer.parseInt(facts.sharesInuse); } catch(Exception e) { duccLogger.trace(methodName, jobid, e); } } row = new StringBuffer(); row.append(""); // Release ALL Stuck JPs row.append(""); String releaseAll = buildReleaseAll(request, factsList); row.append(releaseAll); row.append(""); // Status row.append(""); row.append(""+"Total"); row.append(""); // IP row.append(""); row.append(""); row.append(""); // Name row.append(""); row.append(""); row.append(""); // Memory: usable row.append(""); row.append(""+sumMemoryEffective); row.append(""); // Memory: total row.append(""); row.append(""+sumMemoryTotal); row.append(""); // Swap: inuse row.append(""); row.append(""+sumSwapInuse); row.append(""); /* // Swap: delta row.append(""); row.append(""+sumSwapDelta); row.append(""); */ // Swap: free row.append(""); row.append(""+sumSwapFree); row.append(""); // C-Groups row.append(""); row.append(""); row.append(""); // Alien PIDs row.append(""); row.append(""+sumAliens); row.append(""); // Shares: total row.append(""); row.append(""+sumSharesTotal); row.append(""); // Shares:inuse row.append(""); row.append(""+sumSharesInuse); row.append(""); // Heartbeat: last row.append(""); row.append(""); row.append(""); row.append(""); data.append(row); // Individual Machines listIterator = factsList.listIterator(); while(listIterator.hasNext()) { MachineFacts facts = listIterator.next(); row = new StringBuffer(); row.append((trGet(counter))); // Release Machine Stuck JPs row.append(""); String releaseMachine = buildReleaseMachine(request, facts); row.append(releaseMachine); row.append(""); // Status StringBuffer sb = new StringBuffer(); String status = facts.status; if(status.equals("down")) { sb.append(""); sb.append(status); sb.append(""); } else if(status.equals("up")) { sb.append(""); sb.append(status); sb.append(""); } else { sb.append(status); } row.append(""); row.append(sb); row.append(""); // IP row.append(""); row.append(facts.ip); row.append(""); // Name row.append(""); row.append(facts.name); row.append(""); // Memory: usable row.append(""); row.append(facts.memoryEffective); row.append(""); // Memory: total row.append(""); if(!status.equals("defined")) { row.append(facts.memoryTotal); } row.append(""); // Swap: inuse sb = new StringBuffer(); String swapping = facts.swapInuse; if(swapping.equals("0")) { sb.append(swapping); } else { sb.append(""); sb.append(swapping); sb.append(""); } row.append(""); if(!status.equals("defined")) { row.append(sb); } row.append(""); /* // Swap: delta sb = new StringBuffer(); String delta = facts.swapDelta; if(delta.equals("0")) { sb.append(delta); } else { sb.append(""); sb.append(delta); sb.append(""); } row.append(""); if(!status.equals("defined")) { row.append(sb); } row.append(""); */ // Swap: free row.append(""); if(!status.equals("defined")) { row.append(facts.swapFree); } row.append(""); // C-Groups boolean isCgroups = facts.cgroups; sb = new StringBuffer(); if(status.equals("up")) { if(isCgroups) { sb.append(""); sb.append("on"); sb.append(""); } else { sb.append(""); sb.append("off"); sb.append(""); } } String cgroups = sb.toString(); row.append(""); row.append(""+cgroups); row.append(""); // Alien PIDs sb = new StringBuffer(); long aliens = facts.aliens.size(); if(aliens == 0) { sb.append(aliens); } else { StringBuffer title = new StringBuffer(); title.append("title="); title.append("\""); for(String pid : facts.aliens) { title.append(pid+" "); } title.append("\""); sb.append(""); sb.append(aliens); sb.append(""); } row.append(""); if(!status.equals("defined")) { row.append(sb); } row.append(""); // Shares int sharesTotal = 0; int sharesInuse = 0; try { int total = Integer.parseInt(facts.sharesTotal); int inuse = Integer.parseInt(facts.sharesInuse); sharesTotal = total; sharesInuse = inuse; } catch(Exception e) { } // Shares: total row.append(""); if(!status.equals("defined")) { row.append(facts.sharesTotal); } row.append(""); // Shares: inuse row.append(""); String span0 = ""; String span1 = ""; if(sharesInuse > sharesTotal) { span0 = ""; } if(!status.equals("defined")) { row.append(span0); row.append(facts.sharesInuse); row.append(span1); } row.append(""); // Heartbeat: last row.append(""); if(!status.equals("defined")) { row.append(facts.heartbeat); } row.append(""); row.append(""); data.append(row); counter++; } } else { row = new StringBuffer(); row.append((trGet(counter))); // Release row.append(""); row.append(""); row.append(""); // Status row.append(""); row.append(""); row.append(""); // IP row.append(""); row.append(""); row.append(""); // Name row.append(""); row.append(""); row.append(""); // Reserve row.append(""); row.append(""); row.append(""); // Memory: total row.append(""); row.append(""); row.append(""); // Swap: inuse row.append(""); row.append(""); row.append(""); // Alien PIDs row.append(""); row.append(""); row.append(""); // Shares: total row.append(""); row.append(""); row.append(""); // Shares:inuse row.append(""); row.append(""); row.append(""); // Heartbeat: last row.append(""); row.append(""); row.append(""); row.append(""); data.append(row); } duccLogger.debug(methodName, jobid, data); response.getWriter().println(data); duccLogger.trace(methodName, jobid, messages.fetch("exit")); } private static DecimalFormat formatter3 = new DecimalFormat("##0.000"); private static String Topic = "Topic"; private void handleServletClassicSystemBroker(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { String methodName = "handleServletClassicBroker"; duccLogger.trace(methodName, jobid, messages.fetch("enter")); StringBuffer sb = new StringBuffer(); BrokerHelper brokerHelper = BrokerHelper.getInstance(); ArrayList entityInfoList = brokerHelper.getFrameworkEntities(); String[] attrNames = { FrameworkAttribute.ConsumerCount.name(), FrameworkAttribute.QueueSize.name(), FrameworkAttribute.MaxEnqueueTime.name(), FrameworkAttribute.AverageEnqueueTime.name(), FrameworkAttribute.MemoryPercentUsage.name(), }; StringBuffer topics = new StringBuffer(); StringBuffer queues = new StringBuffer(); if(entityInfoList.size() > 0) { for(EntityInfo entityInfo : entityInfoList) { String name = entityInfo.getName(); String type = entityInfo.getType(); TreeMap map = brokerHelper.getAttributes(name, attrNames); String attrValue = ""; StringBuffer row = new StringBuffer(); row.append(messages.fetch("")); // name row.append(messages.fetch("")); row.append(messages.fetch(name)); row.append(messages.fetch("")); // type row.append(messages.fetch("")); row.append(messages.fetch(type)); row.append(messages.fetch("")); // ConsumerCount attrValue = map.get(FrameworkAttribute.ConsumerCount.name()); row.append(messages.fetch("")); row.append(messages.fetch(attrValue)); row.append(messages.fetch("")); // QueueSize attrValue = map.get(FrameworkAttribute.QueueSize.name()); row.append(messages.fetch("")); row.append(messages.fetch(attrValue)); row.append(messages.fetch("")); // MaxEnqueueTime attrValue = map.get(FrameworkAttribute.MaxEnqueueTime.name()); row.append(messages.fetch("")); row.append(messages.fetch(attrValue)); row.append(messages.fetch("")); // AverageEnqueueTime attrValue = map.get(FrameworkAttribute.AverageEnqueueTime.name()); try { Double d = Double.valueOf(attrValue); attrValue = formatter3.format(d); } catch(Exception e) { } row.append(messages.fetch("")); row.append(messages.fetch(attrValue)); row.append(messages.fetch("")); // MemoryPercentUsage attrValue = map.get(FrameworkAttribute.MemoryPercentUsage.name()); row.append(messages.fetch("")); row.append(messages.fetch(attrValue)); row.append(messages.fetch("")); // row.append(messages.fetch("")); if(type.equals(Topic)) { topics.append(row); } else { queues.append(row); } } sb.append(topics); sb.append(queues); } else { StringBuffer row = new StringBuffer(); row.append(messages.fetch("")); // name row.append(messages.fetch("")); row.append(messages.fetch("no data")); row.append(messages.fetch("")); // ConsumerCount row.append(messages.fetch("")); row.append(messages.fetch("")); row.append(messages.fetch("")); // MaxEnqueueTime row.append(messages.fetch("")); row.append(messages.fetch("")); row.append(messages.fetch("")); // AverageEnqueueTime row.append(messages.fetch("")); row.append(messages.fetch("")); row.append(messages.fetch("")); // MemoryPercentUsage row.append(messages.fetch("")); row.append(messages.fetch("")); row.append(messages.fetch("")); // row.append(messages.fetch("")); sb.append(row); } duccLogger.debug(methodName, jobid, sb); response.getWriter().println(sb); duccLogger.trace(methodName, jobid, messages.fetch("exit")); } private void handleServletUnknown(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { String methodName = "handleServletUnknown"; duccLogger.trace(methodName, jobid, messages.fetch("enter")); duccLogger.info(methodName, jobid, request.toString()); duccLogger.trace(methodName, jobid, messages.fetch("exit")); } private void handleDuccRequest(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws Exception { String methodName = "handleDuccRequest"; duccLogger.trace(methodName, jobid, messages.fetch("enter")); duccLogger.debug(methodName, jobid,request.toString()); duccLogger.debug(methodName, jobid,"getRequestURI():"+request.getRequestURI()); String reqURI = request.getRequestURI()+""; if(reqURI.startsWith(classicJobs)) { handleServletClassicJobs(target, baseRequest, request, response); } else if(reqURI.startsWith(classicReservations)) { handleServletClassicReservations(target, baseRequest, request, response); } else if(reqURI.startsWith(classicServices)) { handleServletClassicServices(target, baseRequest, request, response); } else if(reqURI.startsWith(classicSystemClasses)) { handleServletClassicSystemClasses(target, baseRequest, request, response); } else if(reqURI.startsWith(classicSystemDaemons)) { handleServletClassicSystemDaemons(target, baseRequest, request, response); } else if(reqURI.startsWith(classicSystemMachines)) { handleServletClassicSystemMachines(target, baseRequest, request, response); } else if(reqURI.startsWith(classicSystemBroker)) { handleServletClassicSystemBroker(target, baseRequest, request, response); } else { handleServletUnknown(target, baseRequest, request, response); } duccLogger.trace(methodName, jobid, messages.fetch("exit")); } public void handle(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { String methodName = "handle"; try{ duccLogger.debug(methodName, jobid,request.toString()); duccLogger.debug(methodName, jobid,"getRequestURI():"+request.getRequestURI()); String reqURI = request.getRequestURI()+""; if(reqURI.startsWith(duccContextClassic)) { response.setContentType("text/html;charset=utf-8"); response.setStatus(HttpServletResponse.SC_OK); baseRequest.setHandled(true); handleDuccRequest(target, baseRequest, request, response); DuccWebUtil.noCache(response); } } catch(Throwable t) { if(isIgnorable(t)) { duccLogger.debug(methodName, jobid, t); } else { duccLogger.info(methodName, jobid, "", t.getMessage(), t); duccLogger.error(methodName, jobid, t); } } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy