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
<script> | |
$(function() { | |
const headerText='<div style="margin:1em 0">Sign up to receive...</div>'; | |
window.addEventListener('hashchange', function() { if (location.hash.startsWith('#/portal')) {setTimeout(function(){$("#ghost-portal-root").find("iframe").contents().find(".gh-portal-content.signup .gh-portal-section").prepend(headerText)},200)}}) | |
setTimeout(function(){ | |
$("#ghost-portal-root").find("iframe").contents().find('.gh-portal-triggerbtn-container').click(function(){setTimeout(function(){$("#ghost-portal-root").find("iframe").contents().find(".gh-portal-content.signup .gh-portal-section").prepend(headerText);},200)}) | |
},200); | |
}); | |
</script> |
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
<script> | |
$(function() { | |
const headerText="Sign up to receive..."; | |
window.addEventListener('hashchange', function() { if (location.hash.startsWith('#/portal')) {setTimeout(function(){$("#ghost-portal-root").find("iframe").contents().find(".gh-portal-content.signup .gh-portal-section").prepend(headerText)},200)}}) | |
setTimeout(function(){ | |
$("#ghost-portal-root").find("iframe").contents().find('.gh-portal-triggerbtn-container').click(function(){setTimeout(function(){$("#ghost-portal-root").find("iframe").contents().find(".gh-portal-content.signup .gh-portal-section").prepend(headerText);},200)}) | |
},200); | |
}); | |
</script> |
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
public void testExecuteFunction() { | |
assertTrue(client.addFunction("ExecuteMyFunction", "io.mark.java_examples.Executables.RunThisCode::addPerson")); | |
assertTrue(client.uploadFile("ExecuteMyFunction", "ExecutableCode-1.0-SNAPSHOT.jar")); | |
assertEquals(client.executeFunction("ExecuteMyFunction", "{\"firstName\":\"Mark\",\"lastName\":\"Kose\",\"age\":30,\"isActive\":false}"),"{\"fullName\":\"Mark Kose\",\"age\":30,\"shouldExerciseMore\":true}"); | |
AddPersonResponse person=(AddPersonResponse)client.executeFunction("ExecuteMyFunction","{\"firstName\":\"Mark\",\"lastName\":\"Kose\",\"age\":30,\"isActive\":false}","java"); | |
assertEquals(person.fullName,"Mark Kose"); | |
assertTrue(person.shouldExerciseMore); | |
} |
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
static JavaExecutorGRPCClient client; | |
@BeforeClass | |
public static void setup() throws Exception { | |
System.out.println("Setting up test environment"); | |
JavaExecutorGRPCServer jes=new JavaExecutorGRPCServer(); | |
jes.startServer(); | |
client = new JavaExecutorGRPCClient("127.0.0.1", 8080); | |
} | |
@AfterClass | |
public static void tearDown() throws Exception { |
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
ExecutionResponse response = blockingStub.execute(reqBuilder.build()); | |
if (response.getOutputOneofCase().equals(ExecutionResponse.OutputOneofCase.JSONOUT)) { | |
return(response.getJsonOut()); | |
}else { | |
ObjectInputStream in = new ObjectInputStream(response.getJavaOut().newInput()); | |
Object obj=in.readObject(); | |
in.close(); | |
return obj; |
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
public Object executeFunction(String functionName,String data,String requestedOutputFormat) { | |
ExecutionRequest.Builder reqBuilder = ExecutionRequest.newBuilder().setName(functionName).setInput(data); | |
if (requestedOutputFormat != null) { | |
reqBuilder.setSerializationFormat(requestedOutputFormat); | |
} |
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
FileInputStream fis = new FileInputStream(System.getProperty("java.io.tmpdir")+ File.separator+fileName); | |
int bufferSize = 256 * 1024; | |
while ((length = bis.read(buffer, 0, bufferSize)) != -1) { | |
requestObserver.onNext( | |
UploadFileRequest.newBuilder().setFileContent(ByteString.copyFrom(buffer, 0, length)).build() | |
); | |
requestObserver.onCompleted(); | |
finishLatch.await(1, TimeUnit.MINUTES); |
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
public boolean uploadFile(String functionName,String fileName) { | |
logger.info("Starting uploadFile function name:"+functionName+" file name:"+fileName); | |
final CountDownLatch finishLatch = new CountDownLatch(1); | |
StreamObserver<UploadFileResponse> responseObserver = new StreamObserver<UploadFileResponse>() { | |
public void onError(Throwable t) { | |
finishLatch.countDown(); | |
} | |
public void onCompleted() { | |
finishLatch.countDown(); |
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
if (request.getSerializationFormat().equals("java")) { | |
ByteString.Output bsOut = ByteString.newOutput(); | |
ObjectOutputStream out = new ObjectOutputStream(bsOut); | |
out.writeObject(returnedObject); | |
resBuilder.setJavaOut(bsOut.toByteString()); | |
bsOut.close(); | |
}else { | |
resBuilder.setJsonOut(gson.toJson(returnedObject)).build(); | |
} |
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
ClassLoader classLoader = FunctionService.class.getClassLoader(); | |
Path jarPath=Paths.get(System.getProperty("java.io.tmpdir")+File.separator+"uploaded"+File.separator+functionName+File.separator+fx.getJarFile()); | |
URLClassLoader urlClassLoader = new URLClassLoader( | |
new URL[]{jarPath.toUri().toURL()}, | |
classLoader); | |
String[] tempArray=fx.getHandler().split("::"); | |
Class executableClass = urlClassLoader.loadClass(tempArray[0]); |
NewerOlder