forked from harbby/sylph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ideal
committed
Jul 22, 2018
1 parent
919a1a6
commit 66eeecc
Showing
116 changed files
with
3,439 additions
and
867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,13 @@ sylph builds use Maven and requires Java 10 or higher. | |
# Clean the build | ||
./gradlew clean | ||
``` | ||
vm | ||
-Dconfig=etc/sylph/sylph.properties | ||
-Dlog4j.file=etc/sylph/sylph-log4j.properties | ||
|
||
env | ||
FLINK_HOME=/ideal/hadoop/flink | ||
HADOOP_CONF_DIR=/ideal/hadoop/hadoop/etc/hadoop | ||
|
||
## Useful mailing lists | ||
1. [email protected] - For discussions about code, design and features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
dependencies { | ||
compile ('io.airlift:configuration:0.171'){ | ||
exclude(module: 'guice') | ||
exclude(module: 'guava') | ||
exclude(module: "guice-multibindings") | ||
} | ||
compile (group: 'com.google.inject.extensions', name: 'guice-multibindings', version: deps.guice){ | ||
exclude(module: "guava") | ||
} | ||
compile (group: 'com.google.inject', name: 'guice', version: deps.guice){ | ||
exclude(module: 'guava') | ||
} | ||
compile group: 'com.google.guava', name: 'guava', version: deps.guava | ||
|
||
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: deps.log4j12 //1.8.0-beta2 | ||
} |
94 changes: 94 additions & 0 deletions
94
ideal-common/src/main/java/ideal/sylph/common/base/ObjectInputStreamProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package ideal.sylph.common.base; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.ObjectStreamClass; | ||
import java.lang.reflect.Field; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.Map; | ||
|
||
public class ObjectInputStreamProxy | ||
extends java.io.ObjectInputStream | ||
{ | ||
private ClassLoader classLoader; | ||
|
||
public ObjectInputStreamProxy(InputStream in) | ||
throws IOException | ||
{ | ||
super(in); | ||
} | ||
|
||
/** | ||
* ObjectInputStreamProxy used by user classLoader | ||
* <p> | ||
* | ||
* @param classLoader used by loadObject | ||
*/ | ||
public ObjectInputStreamProxy(InputStream in, ClassLoader classLoader) | ||
throws IOException | ||
{ | ||
super(in); | ||
this.classLoader = classLoader; | ||
} | ||
|
||
/** | ||
* get Method LatestUserDefinedLoader with java.io.ObjectInputStreamProxy | ||
* with jdk.internal.misc.VM.latestUserDefinedLoader() | ||
*/ | ||
public static ClassLoader getLatestUserDefinedLoader() | ||
{ | ||
//super.latestUserDefinedLoader(); | ||
Class<?> class1 = java.io.ObjectInputStream.class; | ||
try { | ||
Method method = class1.getDeclaredMethod("latestUserDefinedLoader"); | ||
method.setAccessible(true); //必须要加这个才能 | ||
return (ClassLoader) method.invoke(null); | ||
} | ||
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { | ||
throw new RuntimeException("Not compatible with java version"); | ||
} | ||
} | ||
|
||
/** | ||
* get field primClasses with java.io.ObjectInputStreamProxy | ||
*/ | ||
private static Map<String, Class<?>> getPrimClasses() | ||
{ | ||
Class<?> class1 = java.io.ObjectInputStream.class; | ||
Map<String, Class<?>> primClasses = null; | ||
try { | ||
Field field = class1.getDeclaredField("primClasses"); | ||
field.setAccessible(true); | ||
primClasses = (Map<String, Class<?>>) field.get(class1); | ||
return primClasses; | ||
} | ||
catch (NoSuchFieldException | IllegalAccessException e) { | ||
throw new RuntimeException("Not compatible with java version"); | ||
} | ||
} | ||
|
||
@Override | ||
protected Class<?> resolveClass(ObjectStreamClass desc) | ||
throws IOException, ClassNotFoundException | ||
{ | ||
if (classLoader == null) { | ||
return super.resolveClass(desc); | ||
} | ||
|
||
//return super.resolveClass(desc); | ||
String name = desc.getName(); | ||
try { | ||
return Class.forName(name, false, classLoader); | ||
} | ||
catch (ClassNotFoundException ex) { | ||
Class<?> cl = getPrimClasses().get(name); | ||
if (cl != null) { | ||
return cl; | ||
} | ||
else { | ||
throw ex; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions
54
ideal-common/src/main/java/ideal/sylph/common/io/IOUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package ideal.sylph.common.io; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.io.PrintStream; | ||
|
||
public class IOUtils | ||
{ | ||
private IOUtils() {} | ||
|
||
/** | ||
* Copies from one stream to another. | ||
* | ||
* @param in InputStrem to read from | ||
* @param out OutputStream to write to | ||
* @param buffSize the size of the buffer | ||
* @param close whether or not close the InputStream and | ||
* OutputStream at the end. The streams are closed in the finally clause. | ||
*/ | ||
public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) | ||
throws IOException | ||
{ | ||
if (close) { | ||
try (InputStream input = in; OutputStream output = out) { | ||
copyBytes(in, out, buffSize); | ||
} | ||
} | ||
else { | ||
copyBytes(in, out, buffSize); | ||
} | ||
} | ||
|
||
/** | ||
* Copies from one stream to another. | ||
* | ||
* @param in InputStrem to read from | ||
* @param out OutputStream to write to | ||
* @param buffSize the size of the buffer | ||
*/ | ||
public static void copyBytes(InputStream in, OutputStream out, int buffSize) | ||
throws IOException | ||
{ | ||
PrintStream ps = out instanceof PrintStream ? (PrintStream) out : null; | ||
byte[] buf = new byte[buffSize]; | ||
int bytesRead = -1; | ||
while ((bytesRead = in.read(buf)) >= 0) { | ||
out.write(buf, 0, bytesRead); | ||
if ((ps != null) && ps.checkError()) { | ||
throw new IOException("Unable to write to output stream."); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
ideal-common/src/main/java/ideal/sylph/common/jvm/JVMUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ideal.sylph.common.jvm; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Collectors; | ||
|
||
public class JVMUtil | ||
{ | ||
private JVMUtil() {} | ||
|
||
/** | ||
* 当前class.path里面所有的jar | ||
*/ | ||
public static Set<File> systemJars() | ||
{ | ||
String[] jars = System.getProperty("java.class.path") | ||
.split(Pattern.quote(File.pathSeparator)); | ||
Set<File> res = Arrays.stream(jars).map(File::new).filter(File::isFile) | ||
.collect(Collectors.toSet()); | ||
//res.forEach(x -> logger.info("systemJars: {}", x)); | ||
//logger.info("flink job systemJars size: {}", res.size()); | ||
return res; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
ideal-common/src/main/java/ideal/sylph/common/memory/MemoryAllocator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ideal.sylph.common.memory; | ||
|
||
public interface MemoryAllocator | ||
{ | ||
/** | ||
* Whether to fill newly allocated and deallocated memory with 0xa5 and 0x5a bytes respectively. | ||
* This helps catch misuse of uninitialized or freed memory, but imposes some overhead. | ||
*/ | ||
boolean MEMORY_DEBUG_FILL_ENABLED = Boolean.parseBoolean( | ||
System.getProperty("spark.memory.debugFill", "false")); | ||
|
||
// Same as jemalloc's debug fill values. | ||
byte MEMORY_DEBUG_FILL_CLEAN_VALUE = (byte) 0xa5; | ||
byte MEMORY_DEBUG_FILL_FREED_VALUE = (byte) 0x5a; | ||
|
||
/** | ||
* Allocates a contiguous block of memory. Note that the allocated memory is not guaranteed | ||
* to be zeroed out (call `fill(0)` on the result if this is necessary). | ||
*/ | ||
MemoryBlock allocate(long size) | ||
throws OutOfMemoryError; | ||
|
||
void free(MemoryBlock memory); | ||
|
||
MemoryAllocator UNSAFE = new UnsafeMemoryAllocator(); | ||
} |
Oops, something went wrong.