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 2019/07/29 12:01:31 UTC
svn commit: r1863933 - in
/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws:
server/DuccHandlerClassic.java server/DuccHandlerJsonFormat.java
utils/DnsHelper.java
Author: degenaro
Date: Mon Jul 29 12:01:31 2019
New Revision: 1863933
URL: http://svn.apache.org/viewvc?rev=1863933&view=rev
Log: (empty)
Added:
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/DnsHelper.java (with props)
Modified:
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java?rev=1863933&r1=1863932&r2=1863933&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerClassic.java Mon Jul 29 12:01:31 2019
@@ -90,6 +90,7 @@ import org.apache.uima.ducc.ws.state.mon
import org.apache.uima.ducc.ws.state.monitoring.NodeState;
import org.apache.uima.ducc.ws.types.NodeId;
import org.apache.uima.ducc.ws.types.UserId;
+import org.apache.uima.ducc.ws.utils.DnsHelper;
import org.apache.uima.ducc.ws.utils.FormatHelper.Precision;
import org.apache.uima.ducc.ws.utils.alien.EffectiveUser;
import org.eclipse.jetty.server.Request;
@@ -1997,6 +1998,9 @@ public class DuccHandlerClassic extends
if(!machines.isEmpty()) {
Map<String, Long> allocatedMap = Distiller.getMap();
for(Entry<MachineInfo, NodeId> entry : machines.entrySet()) {
+ if(!DnsHelper.isKnownHost(entry.getValue())) {
+ continue; // skip host if not known to nameserver
+ }
MachineInfo machineInfo = entry.getKey();
SizeBytes sb = new SizeBytes(Type.Bytes, 0);
if(DuccMachinesDataHelper.isUp(machineInfo)) {
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java?rev=1863933&r1=1863932&r2=1863933&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java Mon Jul 29 12:01:31 2019
@@ -100,6 +100,7 @@ import org.apache.uima.ducc.ws.state.mon
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.apache.uima.ducc.ws.utils.DnsHelper;
import org.apache.uima.ducc.ws.utils.HandlersHelper;
import org.apache.uima.ducc.ws.utils.alien.EffectiveUser;
import org.apache.uima.ducc.ws.utils.alien.FileInfo;
@@ -1993,6 +1994,9 @@ public class DuccHandlerJsonFormat exten
if(!machines.isEmpty()) {
Map<String, Long> allocatedMap = Distiller.getMap();
for(Entry<MachineInfo, NodeId> entry : machines.entrySet()) {
+ if(!DnsHelper.isKnownHost(entry.getValue())) {
+ continue; // skip host if not known to nameserver
+ }
MachineInfo machineInfo = entry.getKey();
SizeBytes sb = new SizeBytes(Type.Bytes, 0);
if(DuccMachinesDataHelper.isUp(machineInfo)) {
Added: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/DnsHelper.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/DnsHelper.java?rev=1863933&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/DnsHelper.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/DnsHelper.java Mon Jul 29 12:01:31 2019
@@ -0,0 +1,91 @@
+/*
+ * 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;
+
+import java.net.InetAddress;
+
+import org.apache.uima.ducc.common.utils.DuccLogger;
+import org.apache.uima.ducc.common.utils.id.DuccId;
+import org.apache.uima.ducc.ws.types.NodeId;
+
+public class DnsHelper {
+
+ private static DuccLogger duccLogger = DuccLogger.getLogger(DnsHelper.class);
+
+ public static boolean isKnowable() {
+ String location = "isKnowable";
+ DuccId jobid = null;
+ boolean retVal = false;
+ try {
+ String result = InetAddress.getLocalHost().getHostName();
+ if(result != null) {
+ if(!result.isEmpty()) {
+ retVal = true;
+ }
+ }
+ }
+ catch(Exception e) {
+ duccLogger.debug(location, jobid, e);
+ }
+ return retVal;
+ }
+
+ // -1 = unknowable
+ // 0 = unknown
+ // 1 = known
+
+ public static int isKnownHost(String hostname) {
+ String location = "isKnownHost";
+ DuccId jobid = null;
+ int retVal = -1;
+ if(hostname != null) {
+ if(isKnowable()) {
+ retVal = 0;
+ try {
+ InetAddress inetAddress = InetAddress.getByName(hostname);
+ if(inetAddress != null) {
+ retVal = 1;
+ }
+ }
+ catch(Exception e) {
+ duccLogger.debug(location, jobid, e);
+ }
+ }
+ String text = hostname+":"+retVal;
+ duccLogger.debug(location, jobid, text);
+ }
+ return retVal;
+ }
+
+ public static boolean isKnownHost(NodeId nodeId) {
+ boolean retVal = true;
+ if(nodeId != null) {
+ if(isKnownHost(nodeId.getLongName()) == 0) {
+ retVal = false;
+ }
+ }
+ return retVal;
+ }
+
+ public static void main(String[] args) {
+ for(String arg : args) {
+ System.out.println(arg+" "+isKnownHost(arg));
+ }
+ }
+}
Propchange: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/DnsHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain