PakhomovAlexander commented on code in PR #6398: URL: https://github.com/apache/ignite-3/pull/6398#discussion_r2289354692
########## examples/src/main/java/org/apache/ignite/example/code/deployment/CodeDeploymentExample.java: ########## @@ -0,0 +1,60 @@ +/* + * 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.ignite.example.code.deployment; + +import org.apache.ignite.client.IgniteClient; +import org.apache.ignite.compute.JobDescriptor; +import org.apache.ignite.compute.JobTarget; +import org.apache.ignite.deployment.DeploymentUnit; + +public class CodeDeploymentExample { + + /** Deployment unit name. */ + private static final String DEPLOYMENT_UNIT_NAME = "codeDeploymentExampleUnit"; + + /** Deployment unit version. */ + private static final String DEPLOYMENT_UNIT_VERSION = "1.0.0"; + + /** + * Main method of the example. + * + * @param args The command line arguments. + */ + public static void main(String[] args) { + + System.out.println("\nConnecting to server..."); + + try (IgniteClient client = IgniteClient.builder() + .addresses("127.0.0.1:10800") + .build() + ) { + + System.out.println("\nConfiguring compute job..."); + + JobDescriptor<String, String> job = JobDescriptor.builder(MyJob.class) + .units(new DeploymentUnit(DEPLOYMENT_UNIT_NAME, DEPLOYMENT_UNIT_VERSION)) + .resultClass(String.class) + .build(); + + JobTarget target = JobTarget.anyNode(client.cluster().nodes()); + System.out.println("\nExecuting compute job'" + "'..."); Review Comment: formatting ########## examples/src/main/java/org/apache/ignite/example/code/deployment/MyJob.java: ########## @@ -0,0 +1,71 @@ +/* + * 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.ignite.example.code.deployment; + +import java.io.OutputStream; +import org.apache.ignite.Ignite; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.JobExecutionContext; + +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.concurrent.CompletableFuture; + +public class MyJob implements ComputeJob<String, String> { + @Override + public CompletableFuture<String> executeAsync(JobExecutionContext ctx, String arg) { + Ignite ignite = ctx.ignite(); + + /** Full path to the script we want to run */ + final String resPath = "/org/apache/ignite/example/code/deployment/resources/script.sh"; Review Comment: Im quite surprised by this example. Why do we show how to run an sh script through out compute API? I mean can we make an example significantly simpler just by running some plain java code? OR this is the main idea of this example like "Look! You can run sh script on our servers!" -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org