You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2015/06/25 12:58:53 UTC
svn commit: r1687473 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws:
server/DuccHandler.java utils/alien/AlienWorkItemStateReader.java
Author: degenaro
Date: Thu Jun 25 10:58:53 2015
New Revision: 1687473
URL: http://svn.apache.org/r1687473
Log:
UIMA-4479 DUCC Web Server (WS) Work Items tab shows no files (on Job Details)
Added:
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/alien/AlienWorkItemStateReader.java (with props)
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java?rev=1687473&r1=1687472&r2=1687473&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java Thu Jun 25 10:58:53 2015
@@ -56,7 +56,6 @@ import org.apache.uima.ducc.common.jd.fi
import org.apache.uima.ducc.common.jd.files.perf.PerformanceMetricsSummaryMap;
import org.apache.uima.ducc.common.jd.files.perf.PerformanceSummary;
import org.apache.uima.ducc.common.jd.files.perf.UimaStatistic;
-import org.apache.uima.ducc.common.jd.files.workitem.WorkItemStateReader;
import org.apache.uima.ducc.common.system.SystemState;
import org.apache.uima.ducc.common.utils.DuccLogger;
import org.apache.uima.ducc.common.utils.DuccLoggerComponents;
@@ -112,6 +111,7 @@ import org.apache.uima.ducc.ws.utils.For
import org.apache.uima.ducc.ws.utils.HandlersHelper;
import org.apache.uima.ducc.ws.utils.LinuxSignals;
import org.apache.uima.ducc.ws.utils.LinuxSignals.Signal;
+import org.apache.uima.ducc.ws.utils.alien.AlienWorkItemStateReader;
import org.apache.uima.ducc.ws.utils.alien.FileInfo;
import org.apache.uima.ducc.ws.utils.alien.OsProxy;
import org.eclipse.jetty.server.Request;
@@ -1605,7 +1605,7 @@ public class DuccHandler extends DuccAbs
String directory = job.getLogDirectory()+jobNo;
String userId = duccWebSessionManager.getUserId(request);
long wiVersion = job.getWiVersion();
- WorkItemStateReader workItemStateReader = new WorkItemStateReader(component, directory, userId, wiVersion);
+ AlienWorkItemStateReader workItemStateReader = new AlienWorkItemStateReader(getDuccling(request), component, directory, userId, wiVersion);
ConcurrentSkipListMap<Long,IWorkItemState> map = workItemStateReader.getMap();
if( (map == null) || (map.size() == 0) ) {
sb.append("no data (map empty?)");
@@ -1769,7 +1769,7 @@ public class DuccHandler extends DuccAbs
String directory = job.getLogDirectory()+jobNo;
String userId = duccWebSessionManager.getUserId(request);
long wiVersion = job.getWiVersion();
- WorkItemStateReader workItemStateReader = new WorkItemStateReader(component, directory, userId, wiVersion);
+ AlienWorkItemStateReader workItemStateReader = new AlienWorkItemStateReader(getDuccling(request), component, directory, userId, wiVersion);
PerformanceSummary performanceSummary = new PerformanceSummary(job.getLogDirectory()+jobNo);
PerformanceMetricsSummaryMap performanceMetricsSummaryMap = performanceSummary.readSummary(userId);
if( (performanceMetricsSummaryMap == null) || (performanceMetricsSummaryMap.size() == 0) ) {
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/alien/AlienWorkItemStateReader.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/alien/AlienWorkItemStateReader.java?rev=1687473&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/alien/AlienWorkItemStateReader.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/alien/AlienWorkItemStateReader.java Thu Jun 25 10:58:53 2015
@@ -0,0 +1,148 @@
+/*
+ * 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.utils.alien;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.lang.reflect.Type;
+import java.util.concurrent.ConcurrentSkipListMap;
+
+import org.apache.uima.ducc.common.jd.files.IWorkItemState;
+import org.apache.uima.ducc.common.jd.files.WorkItemState;
+import org.apache.uima.ducc.common.jd.files.workitem.WorkItemStateReader;
+import org.apache.uima.ducc.common.utils.AlienFile;
+import org.apache.uima.ducc.common.utils.DuccLogger;
+
+import com.google.gson.reflect.TypeToken;
+
+public class AlienWorkItemStateReader extends WorkItemStateReader {
+
+ protected DuccLogger logger = DuccLogger.getLogger(AlienWorkItemStateReader.class, null);
+
+ private String ducc_ling = null;
+ private String user = null;
+
+ private long MaxRecords = 4096;
+
+ public AlienWorkItemStateReader(String ducc_ling, String component, String directory, String user, long wiVersion) {
+ super(component, directory, user, wiVersion);
+ set_ducc_ling(ducc_ling);
+ set_user(user);
+ }
+
+ private void set_ducc_ling(String value) {
+ ducc_ling = value;
+ }
+
+ private void set_user(String value) {
+ user = value;
+ }
+
+
+ @Override
+ public ConcurrentSkipListMap<Long,IWorkItemState> getMap() {
+ long lastRecordNo = 0;
+ long maxRecords = MaxRecords;
+ return getMap(lastRecordNo, maxRecords);
+ }
+
+ private ConcurrentSkipListMap<Long,IWorkItemState> getMap(long lastRecordNo, long maxRecords) {
+ String location = "getMap";
+ ConcurrentSkipListMap<Long,IWorkItemState> map = null;
+ if(ducc_ling == null) {
+ map = super.getMap();
+ }
+ else {
+ map = new ConcurrentSkipListMap<Long,IWorkItemState>();
+ fetch(map,fnActiveJson);
+ int sizeActive = map.size();
+ fetch(map,fnJson);
+ int sizeInactive = map.size() - sizeActive;
+ logger.debug(location, jobid, "active:"+sizeActive+" "+"inactive:"+sizeInactive);
+ }
+ return map;
+ }
+
+ private Type wisType = new TypeToken<WorkItemState>() { }.getType();
+
+ private IWorkItemState convert(ConcurrentSkipListMap<Long,IWorkItemState> map, String line) {
+ StringReader sr = new StringReader(line.trim());
+ WorkItemState wis = gson.fromJson(sr, wisType);
+ Long key = Long.parseLong(wis.getSeqNo());
+ IWorkItemState value = wis;
+ map.put(key, value);
+ return wis;
+ }
+
+ private void fetch(ConcurrentSkipListMap<Long,IWorkItemState> map, String fn) {
+ String location = "fetch";
+ AlienFile alienFile = new AlienFile(user, fn, ducc_ling);
+ InputStreamReader isr = null;
+ BufferedReader br = null;
+ try {
+ isr = alienFile.getInputStreamReader();
+ br = new BufferedReader(isr);
+ String line;
+ while ((line = br.readLine()) != null) {
+ logger.debug(location, jobid, line);
+ IWorkItemState wis = convert(map,line);;
+ if(wis != null) {
+ try {
+ long key = Long.parseLong(wis.getSeqNo());
+ map.put(key, wis);
+ }
+ catch(Exception e) {
+ logger.error(location, jobid, wis.getSeqNo(), e);
+ }
+
+ }
+ }
+ }
+ catch(FileNotFoundException e) {
+ logger.debug(location, jobid, "File not found");
+ }
+ catch(IOException e) {
+ logger.debug(location, jobid, "File error");
+ }
+ catch(Throwable t) {
+ logger.error(location, jobid, t);
+ }
+ }
+
+ @Override
+ public double getMin() {
+ double retVal = 0;
+ return retVal;
+ }
+
+ @Override
+ public double getMax() {
+ double retVal = 0;
+ return retVal;
+ }
+
+ @Override
+ public double getAvg() {
+ double retVal = 0;
+ return retVal;
+ }
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/alien/AlienWorkItemStateReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/alien/AlienWorkItemStateReader.java
------------------------------------------------------------------------------
svn:mime-type = text/plain