Skip to content

Commit

Permalink
fix code build
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 2, 2020
1 parent 6840462 commit be7d0e8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.

This file was deleted.

1 change: 0 additions & 1 deletion sylph-web/src/main/webapp/node_modules/.bin/url-loader

This file was deleted.

This file was deleted.

This file was deleted.

23 changes: 20 additions & 3 deletions sylph-yarn/src/main/java/ideal/sylph/runtime/local/Kernel32.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
/*
* Copyright (C) 2018 The Sylph Authors
*
* 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.
*/
package ideal.sylph.runtime.local;

import com.sun.jna.Library;
import com.sun.jna.Native;

public interface Kernel32 extends Library {
public interface Kernel32
extends Library
{
Kernel32 INSTANCE = (Kernel32) Native.load("kernel32", Kernel32.class);
long GetProcessId(Long hProcess);
}

long getProcessId(Long hProcess);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import ideal.sylph.spi.job.JobContainerAbs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Field;
import java.util.concurrent.Future;

Expand All @@ -44,7 +45,7 @@ public String getRunId()
}
else {
//todo: widnows get pid not return "windows";
logger.debug("#### win 获取 "+getProcessId(process));
logger.debug("#### win 获取 " + getProcessId(process));
return getProcessId(process);
}
}
Expand Down Expand Up @@ -101,24 +102,28 @@ public Status getStatus()
return super.getStatus();
}

public static String getProcessId(Process process) {
public static String getProcessId(Process process)
{
long pid = -1;
Field field = null;
if (Platform.isWindows()) {
try {
field = process.getClass().getDeclaredField("handle");
field.setAccessible(true);
pid = Kernel32.INSTANCE.GetProcessId((Long) field.get(process));
} catch (Exception ex) {
pid = Kernel32.INSTANCE.getProcessId((Long) field.get(process));
}
catch (Exception ex) {
ex.printStackTrace();
}
} else if (Platform.isLinux() || Platform.isAIX()) {
}
else if (Platform.isLinux() || Platform.isAIX()) {
try {
Class<?> clazz = Class.forName("java.lang.UNIXProcess");
field = clazz.getDeclaredField("pid");
field.setAccessible(true);
pid = (Integer) field.get(process);
} catch (Throwable e) {
}
catch (Throwable e) {
e.printStackTrace();
}
}
Expand Down

0 comments on commit be7d0e8

Please sign in to comment.