[GitHub] [helix] narendly commented on a change in pull request #410: Fix the execution delay for the jobs (409)

2019-08-18 Thread GitBox
narendly commented on a change in pull request #410: Fix the execution delay 
for the jobs (409)
URL: https://github.com/apache/helix/pull/410#discussion_r315043967
 
 

 ##
 File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestExecutionDelay.java
 ##
 @@ -0,0 +1,124 @@
+package org.apache.helix.integration.task;
+
+/*
+ * 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.
+ */
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import java.util.List;
+import org.apache.helix.HelixAdmin;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixException;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.TestHelper;
+import org.apache.helix.task.JobConfig;
+import org.apache.helix.task.JobContext;
+import org.apache.helix.task.JobQueue;
+import org.apache.helix.task.TaskConstants;
+import org.apache.helix.task.TaskState;
+import org.apache.helix.task.TaskUtil;
+import org.apache.helix.task.Workflow;
+import org.apache.helix.task.WorkflowContext;
+import 
org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Test To check if the Execution Delay is respected.
+ */
+public class TestExecutionDelay extends TaskTestBase {
+
+  @BeforeClass
+  public void beforeClass() throws Exception {
+super.beforeClass();
+  }
+
+  @Test
+  public void testExecutionDelay() throws Exception {
+// Execution Delay is set to be a large number. Hence, the workflow should 
not be completed
+// soon.
+final long executionDelay = 1000L;
+String workflowName = TestHelper.getTestMethodName();
+Workflow.Builder builder = new Workflow.Builder(workflowName);
+
+// Workflow DAG Schematic:
+//  JOB0
+//   /\
+//  /  \
+// /\
+//   JOB1   JOB2
+
+JobConfig.Builder jobBuilder = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder2 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder3 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+builder.addParentChildDependency("JOB0", "JOB1");
+builder.addParentChildDependency("JOB0", "JOB2");
+builder.addJob("JOB0", jobBuilder.setExecutionDelay(executionDelay));
+builder.addJob("JOB1", jobBuilder2);
+builder.addJob("JOB2", jobBuilder3);
+
+// Since the execution delay is set as a long time, it is expected to 
reach time out.
+// If the workflow completed without any exception, it means that 
ExecutionDelay has not been
+// respected.
+_driver.start(builder.build());
+
+// Verify workflow Context is created.
+// Wait until Workflow Context is created.
+boolean resultWorkflow = TestHelper.verify(() -> {
+  WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName);
+  return (wCtx1 != null);
+}, 60 * 1000);
+Assert.assertTrue(resultWorkflow);
+
+// Verify StartTime is set for the Job.
+// Wait until startTime is set.
+boolean resultStartTime = TestHelper.verify(() -> {
+  WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName);
+  long startTime = -1;
+  try {
+startTime = 
wCtx1.getJobStartTime(TaskUtil.getNamespacedJobName(workflowName, "JOB0"));
+  } catch (Exception e) {
+// pass
+  }
+  return (startTime != -1);
+}, 60 * 1000);
+Assert.assertTrue(resultStartTime);
+
+// Verify Job Context is not created. If Job Context is created, it means 
that the execution
+// delay is not respected. if not 

[GitHub] [helix] narendly commented on a change in pull request #410: Fix the execution delay for the jobs (409)

2019-08-18 Thread GitBox
narendly commented on a change in pull request #410: Fix the execution delay 
for the jobs (409)
URL: https://github.com/apache/helix/pull/410#discussion_r315043520
 
 

 ##
 File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestExecutionDelay.java
 ##
 @@ -0,0 +1,124 @@
+package org.apache.helix.integration.task;
+
+/*
+ * 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.
+ */
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import java.util.List;
+import org.apache.helix.HelixAdmin;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixException;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.TestHelper;
+import org.apache.helix.task.JobConfig;
+import org.apache.helix.task.JobContext;
+import org.apache.helix.task.JobQueue;
+import org.apache.helix.task.TaskConstants;
+import org.apache.helix.task.TaskState;
+import org.apache.helix.task.TaskUtil;
+import org.apache.helix.task.Workflow;
+import org.apache.helix.task.WorkflowContext;
+import 
org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Test To check if the Execution Delay is respected.
+ */
+public class TestExecutionDelay extends TaskTestBase {
+
+  @BeforeClass
+  public void beforeClass() throws Exception {
+super.beforeClass();
+  }
+
+  @Test
+  public void testExecutionDelay() throws Exception {
+// Execution Delay is set to be a large number. Hence, the workflow should 
not be completed
+// soon.
+final long executionDelay = 1000L;
+String workflowName = TestHelper.getTestMethodName();
+Workflow.Builder builder = new Workflow.Builder(workflowName);
+
+// Workflow DAG Schematic:
+//  JOB0
+//   /\
+//  /  \
+// /\
+//   JOB1   JOB2
+
+JobConfig.Builder jobBuilder = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder2 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder3 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+builder.addParentChildDependency("JOB0", "JOB1");
+builder.addParentChildDependency("JOB0", "JOB2");
+builder.addJob("JOB0", jobBuilder.setExecutionDelay(executionDelay));
+builder.addJob("JOB1", jobBuilder2);
+builder.addJob("JOB2", jobBuilder3);
+
+// Since the execution delay is set as a long time, it is expected to 
reach time out.
+// If the workflow completed without any exception, it means that 
ExecutionDelay has not been
+// respected.
+_driver.start(builder.build());
+
+// Verify workflow Context is created.
+// Wait until Workflow Context is created.
+boolean resultWorkflow = TestHelper.verify(() -> {
 
 Review comment:
   Minor: 
   Boolean naming convention
   
https://stackoverflow.com/questions/40339847/variable-and-method-naming-conventions-for-boolean-verbs-in-java
   
   workflowCreated might be a better option here?
   


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org
For additional commands, e-mail: reviews-h...@helix.apache.org



[GitHub] [helix] narendly commented on a change in pull request #410: Fix the execution delay for the jobs (409)

2019-08-18 Thread GitBox
narendly commented on a change in pull request #410: Fix the execution delay 
for the jobs (409)
URL: https://github.com/apache/helix/pull/410#discussion_r315043805
 
 

 ##
 File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestExecutionDelay.java
 ##
 @@ -0,0 +1,124 @@
+package org.apache.helix.integration.task;
+
+/*
+ * 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.
+ */
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import java.util.List;
+import org.apache.helix.HelixAdmin;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixException;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.TestHelper;
+import org.apache.helix.task.JobConfig;
+import org.apache.helix.task.JobContext;
+import org.apache.helix.task.JobQueue;
+import org.apache.helix.task.TaskConstants;
+import org.apache.helix.task.TaskState;
+import org.apache.helix.task.TaskUtil;
+import org.apache.helix.task.Workflow;
+import org.apache.helix.task.WorkflowContext;
+import 
org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Test To check if the Execution Delay is respected.
+ */
+public class TestExecutionDelay extends TaskTestBase {
+
+  @BeforeClass
+  public void beforeClass() throws Exception {
+super.beforeClass();
+  }
+
+  @Test
+  public void testExecutionDelay() throws Exception {
+// Execution Delay is set to be a large number. Hence, the workflow should 
not be completed
+// soon.
+final long executionDelay = 1000L;
+String workflowName = TestHelper.getTestMethodName();
+Workflow.Builder builder = new Workflow.Builder(workflowName);
+
+// Workflow DAG Schematic:
+//  JOB0
+//   /\
+//  /  \
+// /\
+//   JOB1   JOB2
+
+JobConfig.Builder jobBuilder = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder2 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder3 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+builder.addParentChildDependency("JOB0", "JOB1");
+builder.addParentChildDependency("JOB0", "JOB2");
+builder.addJob("JOB0", jobBuilder.setExecutionDelay(executionDelay));
+builder.addJob("JOB1", jobBuilder2);
+builder.addJob("JOB2", jobBuilder3);
+
+// Since the execution delay is set as a long time, it is expected to 
reach time out.
+// If the workflow completed without any exception, it means that 
ExecutionDelay has not been
+// respected.
+_driver.start(builder.build());
+
+// Verify workflow Context is created.
+// Wait until Workflow Context is created.
+boolean resultWorkflow = TestHelper.verify(() -> {
+  WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName);
+  return (wCtx1 != null);
+}, 60 * 1000);
+Assert.assertTrue(resultWorkflow);
+
+// Verify StartTime is set for the Job.
+// Wait until startTime is set.
+boolean resultStartTime = TestHelper.verify(() -> {
+  WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName);
+  long startTime = -1;
+  try {
+startTime = 
wCtx1.getJobStartTime(TaskUtil.getNamespacedJobName(workflowName, "JOB0"));
+  } catch (Exception e) {
+// pass
+  }
+  return (startTime != -1);
 
 Review comment:
   parentheses not needed.


This is an automated message from the Apache Git Service.
To respond to the message, 

[GitHub] [helix] narendly commented on a change in pull request #410: Fix the execution delay for the jobs (409)

2019-08-18 Thread GitBox
narendly commented on a change in pull request #410: Fix the execution delay 
for the jobs (409)
URL: https://github.com/apache/helix/pull/410#discussion_r315044176
 
 

 ##
 File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestExecutionDelay.java
 ##
 @@ -0,0 +1,124 @@
+package org.apache.helix.integration.task;
+
+/*
+ * 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.
+ */
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import java.util.List;
+import org.apache.helix.HelixAdmin;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixException;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.TestHelper;
+import org.apache.helix.task.JobConfig;
+import org.apache.helix.task.JobContext;
+import org.apache.helix.task.JobQueue;
+import org.apache.helix.task.TaskConstants;
+import org.apache.helix.task.TaskState;
+import org.apache.helix.task.TaskUtil;
+import org.apache.helix.task.Workflow;
+import org.apache.helix.task.WorkflowContext;
+import 
org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Test To check if the Execution Delay is respected.
+ */
+public class TestExecutionDelay extends TaskTestBase {
+
+  @BeforeClass
+  public void beforeClass() throws Exception {
+super.beforeClass();
+  }
+
+  @Test
+  public void testExecutionDelay() throws Exception {
+// Execution Delay is set to be a large number. Hence, the workflow should 
not be completed
+// soon.
+final long executionDelay = 1000L;
+String workflowName = TestHelper.getTestMethodName();
+Workflow.Builder builder = new Workflow.Builder(workflowName);
+
+// Workflow DAG Schematic:
+//  JOB0
+//   /\
+//  /  \
+// /\
+//   JOB1   JOB2
+
+JobConfig.Builder jobBuilder = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder2 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder3 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+builder.addParentChildDependency("JOB0", "JOB1");
+builder.addParentChildDependency("JOB0", "JOB2");
+builder.addJob("JOB0", jobBuilder.setExecutionDelay(executionDelay));
+builder.addJob("JOB1", jobBuilder2);
+builder.addJob("JOB2", jobBuilder3);
+
+// Since the execution delay is set as a long time, it is expected to 
reach time out.
+// If the workflow completed without any exception, it means that 
ExecutionDelay has not been
+// respected.
+_driver.start(builder.build());
+
+// Verify workflow Context is created.
+// Wait until Workflow Context is created.
+boolean resultWorkflow = TestHelper.verify(() -> {
+  WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName);
+  return (wCtx1 != null);
+}, 60 * 1000);
+Assert.assertTrue(resultWorkflow);
+
+// Verify StartTime is set for the Job.
+// Wait until startTime is set.
+boolean resultStartTime = TestHelper.verify(() -> {
+  WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName);
+  long startTime = -1;
+  try {
+startTime = 
wCtx1.getJobStartTime(TaskUtil.getNamespacedJobName(workflowName, "JOB0"));
+  } catch (Exception e) {
+// pass
+  }
+  return (startTime != -1);
+}, 60 * 1000);
+Assert.assertTrue(resultStartTime);
+
+// Verify Job Context is not created. If Job Context is created, it means 
that the execution
+// delay is not respected. if not 

[GitHub] [helix] narendly commented on a change in pull request #410: Fix the execution delay for the jobs (409)

2019-08-18 Thread GitBox
narendly commented on a change in pull request #410: Fix the execution delay 
for the jobs (409)
URL: https://github.com/apache/helix/pull/410#discussion_r315042991
 
 

 ##
 File path: 
helix-core/src/main/java/org/apache/helix/task/WorkflowDispatcher.java
 ##
 @@ -602,4 +590,33 @@ private void removeContextsAndPreviousAssignment(String 
workflow, Set jo
 }
 cache.removeContext(workflow);
   }
+
+  private long computeStartTimeForJob(WorkflowContext workflowCtx, String job,
+  JobConfig jobConfig) {
+// Since the start time is calculated base on the time of completion of 
parent jobs for this
+// job, the calculated start time should only be calculated once. Persist 
the calculated time
+// in WorkflowContext znode.
+long calculatedStartTime = workflowCtx.getJobStartTime(job);
+if (calculatedStartTime < 0) {
+  // Calculate the start time if it is not already calculated
+  calculatedStartTime = System.currentTimeMillis();
+  // If the start time is not calculated before, do the math.
+  if (jobConfig.getExecutionDelay() >= 0) {
+calculatedStartTime += jobConfig.getExecutionDelay();
+  }
+  calculatedStartTime = Math.max(calculatedStartTime, 
jobConfig.getExecutionStart());
+  workflowCtx.setJobStartTime(job, calculatedStartTime);
+}
+return calculatedStartTime;
+  }
+
+  private boolean isJobReadyToExecute(WorkflowContext workflowCtx, String job) 
{
+long calculatedStartTime = workflowCtx.getJobStartTime(job);
+long timeNow = System.currentTimeMillis();
+if (timeNow < calculatedStartTime) {
 
 Review comment:
   This method could be simplified to:
   
   `return System.currentTimeMillis() >= workflowCtx.getJobStartTime(job);`
   
   Also, are we sure that there's no other checks required in this function? If 
it's just going to be a one-liner (in other words, there are no other checks to 
perform than checking the calculatedStartTime against current time to determine 
if a job is ready to be processed/updated), and if the usage is only in this 
place, perhaps it may not be worth it to make it a separate function. If that's 
the case, let's just keep what we had inline.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org
For additional commands, e-mail: reviews-h...@helix.apache.org



[GitHub] [helix] narendly commented on a change in pull request #410: Fix the execution delay for the jobs (409)

2019-08-18 Thread GitBox
narendly commented on a change in pull request #410: Fix the execution delay 
for the jobs (409)
URL: https://github.com/apache/helix/pull/410#discussion_r315044366
 
 

 ##
 File path: 
helix-core/src/test/java/org/apache/helix/integration/task/TestExecutionDelay.java
 ##
 @@ -0,0 +1,124 @@
+package org.apache.helix.integration.task;
+
+/*
+ * 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.
+ */
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import java.util.List;
+import org.apache.helix.HelixAdmin;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixException;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.TestHelper;
+import org.apache.helix.task.JobConfig;
+import org.apache.helix.task.JobContext;
+import org.apache.helix.task.JobQueue;
+import org.apache.helix.task.TaskConstants;
+import org.apache.helix.task.TaskState;
+import org.apache.helix.task.TaskUtil;
+import org.apache.helix.task.Workflow;
+import org.apache.helix.task.WorkflowContext;
+import 
org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Test To check if the Execution Delay is respected.
+ */
+public class TestExecutionDelay extends TaskTestBase {
+
+  @BeforeClass
+  public void beforeClass() throws Exception {
+super.beforeClass();
+  }
+
+  @Test
+  public void testExecutionDelay() throws Exception {
+// Execution Delay is set to be a large number. Hence, the workflow should 
not be completed
+// soon.
+final long executionDelay = 1000L;
+String workflowName = TestHelper.getTestMethodName();
+Workflow.Builder builder = new Workflow.Builder(workflowName);
+
+// Workflow DAG Schematic:
+//  JOB0
+//   /\
+//  /  \
+// /\
+//   JOB1   JOB2
+
+JobConfig.Builder jobBuilder = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder2 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+JobConfig.Builder jobBuilder3 = 
JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG)
+.setMaxAttemptsPerTask(1).setWorkflow(workflowName)
+.setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "1000"));
+
+builder.addParentChildDependency("JOB0", "JOB1");
+builder.addParentChildDependency("JOB0", "JOB2");
+builder.addJob("JOB0", jobBuilder.setExecutionDelay(executionDelay));
+builder.addJob("JOB1", jobBuilder2);
+builder.addJob("JOB2", jobBuilder3);
+
+// Since the execution delay is set as a long time, it is expected to 
reach time out.
+// If the workflow completed without any exception, it means that 
ExecutionDelay has not been
+// respected.
+_driver.start(builder.build());
+
+// Verify workflow Context is created.
+// Wait until Workflow Context is created.
+boolean resultWorkflow = TestHelper.verify(() -> {
+  WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName);
+  return (wCtx1 != null);
+}, 60 * 1000);
+Assert.assertTrue(resultWorkflow);
+
+// Verify StartTime is set for the Job.
+// Wait until startTime is set.
+boolean resultStartTime = TestHelper.verify(() -> {
+  WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName);
+  long startTime = -1;
+  try {
+startTime = 
wCtx1.getJobStartTime(TaskUtil.getNamespacedJobName(workflowName, "JOB0"));
+  } catch (Exception e) {
+// pass
+  }
+  return (startTime != -1);
+}, 60 * 1000);
+Assert.assertTrue(resultStartTime);
+
+// Verify Job Context is not created. If Job Context is created, it means 
that the execution
+// delay is not respected. if not 

[GitHub] [helix] narendly opened a new issue #419: Add BucketDataAccessor to persist assignment metadata

2019-08-18 Thread GitBox
narendly opened a new issue #419: Add BucketDataAccessor to persist assignment 
metadata
URL: https://github.com/apache/helix/issues/419
 
 
   For the new rebalancer (WAGED), we need to have a way to persist potentially 
large amounts of data (assignment metadata for the entire cluster) in 
ZooKeeper. This issue tracks the work of implementing a data accessor. See 
https://github.com/apache/helix/wiki/Storing-Assignment-Metadata-in-ZooKeeper


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org
For additional commands, e-mail: reviews-h...@helix.apache.org