Repository: aurora Updated Branches: refs/heads/master c1b0dce41 -> be75c36f6
Use JDK 8 language features. Bugs closed: AURORA-274 Reviewed at https://reviews.apache.org/r/34126/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/be75c36f Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/be75c36f Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/be75c36f Branch: refs/heads/master Commit: be75c36f6ce0b2ca6cc7a910b64e2bb9ca40953d Parents: c1b0dce Author: Bill Farner <[email protected]> Authored: Tue May 12 16:42:59 2015 -0700 Committer: Bill Farner <[email protected]> Committed: Tue May 12 16:43:22 2015 -0700 ---------------------------------------------------------------------- NEWS | 4 + build.gradle | 6 +- examples/vagrant/provision-dev-cluster.sh | 6 +- .../preemptor/PendingTaskProcessorTest.java | 88 ++++++++------------ .../storage/backup/StorageBackupTest.java | 5 +- 5 files changed, 52 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/be75c36f/NEWS ---------------------------------------------------------------------- diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..a17f0e7 --- /dev/null +++ b/NEWS @@ -0,0 +1,4 @@ +0.9.0 +----- + +- Now requires JRE 8 or greater. http://git-wip-us.apache.org/repos/asf/aurora/blob/be75c36f/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index ec9b522..700e1ad 100644 --- a/build.gradle +++ b/build.gradle @@ -42,8 +42,8 @@ allprojects { } compileJava { - sourceCompatibility = 1.7 - targetCompatibility = 1.7 + sourceCompatibility = 1.8 + targetCompatibility = 1.8 } group 'org.apache.aurora' @@ -163,6 +163,8 @@ project(':api') { idea { module { + jdkName = '1.8' + [thrift.genJavaDir, thriftEntities.genJavaDir].each { sourceDirs += it generatedSourceDirs += it http://git-wip-us.apache.org/repos/asf/aurora/blob/be75c36f/examples/vagrant/provision-dev-cluster.sh ---------------------------------------------------------------------- diff --git a/examples/vagrant/provision-dev-cluster.sh b/examples/vagrant/provision-dev-cluster.sh index 2c5ce97..853ccac 100755 --- a/examples/vagrant/provision-dev-cluster.sh +++ b/examples/vagrant/provision-dev-cluster.sh @@ -15,6 +15,7 @@ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list +add-apt-repository ppa:openjdk-r/ppa -y apt-get update apt-get -y install \ bison \ @@ -25,12 +26,11 @@ apt-get -y install \ libsasl2-dev \ libsvn-dev \ lxc-docker \ - openjdk-7-jdk \ + openjdk-8-jdk \ python-dev \ zookeeper -# Ensure java 7 is the default java. -update-alternatives --set java /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java +update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java readonly IP_ADDRESS=192.168.33.7 http://git-wip-us.apache.org/repos/asf/aurora/blob/be75c36f/src/test/java/org/apache/aurora/scheduler/async/preemptor/PendingTaskProcessorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/aurora/scheduler/async/preemptor/PendingTaskProcessorTest.java b/src/test/java/org/apache/aurora/scheduler/async/preemptor/PendingTaskProcessorTest.java index 218ae0d..0280a0b 100644 --- a/src/test/java/org/apache/aurora/scheduler/async/preemptor/PendingTaskProcessorTest.java +++ b/src/test/java/org/apache/aurora/scheduler/async/preemptor/PendingTaskProcessorTest.java @@ -17,12 +17,10 @@ import java.util.Arrays; import javax.annotation.Nullable; -import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; - import com.twitter.common.quantity.Amount; import com.twitter.common.quantity.Time; import com.twitter.common.testing.easymock.EasyMockTest; @@ -41,7 +39,6 @@ import org.apache.aurora.scheduler.base.Query; import org.apache.aurora.scheduler.base.TaskGroupKey; import org.apache.aurora.scheduler.filter.AttributeAggregate; import org.apache.aurora.scheduler.stats.CachedCounters; -import org.apache.aurora.scheduler.storage.entities.IAssignedTask; import org.apache.aurora.scheduler.storage.entities.IHostAttributes; import org.apache.aurora.scheduler.storage.entities.IScheduledTask; import org.apache.aurora.scheduler.storage.entities.ITaskConfig; @@ -59,6 +56,7 @@ import static org.apache.aurora.scheduler.async.preemptor.PreemptorMetrics.slotS import static org.easymock.EasyMock.anyObject; import static org.easymock.EasyMock.eq; import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.expectLastCall; import static org.junit.Assert.assertEquals; public class PendingTaskProcessorTest extends EasyMockTest { @@ -67,8 +65,8 @@ public class PendingTaskProcessorTest extends EasyMockTest { private static final String SLAVE_ID_2 = "slave_id_2"; private static final JobKey JOB_A = new JobKey("role_a", "env", "job_a"); private static final JobKey JOB_B = new JobKey("role_b", "env", "job_b"); - private static final ScheduledTask TASK_A = makeTask(JOB_A, SLAVE_ID_1, "id1"); - private static final ScheduledTask TASK_B = makeTask(JOB_B, SLAVE_ID_2, "id2"); + private static final IScheduledTask TASK_A = makeTask(JOB_A, SLAVE_ID_1, "id1"); + private static final IScheduledTask TASK_B = makeTask(JOB_B, SLAVE_ID_2, "id2"); private static final PreemptionProposal SLOT_A = createPreemptionProposal(TASK_A, SLAVE_ID_1); private static final Amount<Long, Time> PREEMPTION_DELAY = Amount.of(30L, Time.SECONDS); private static final Amount<Long, Time> EXPIRATION = Amount.of(10L, Time.MINUTES); @@ -106,6 +104,7 @@ public class PendingTaskProcessorTest extends EasyMockTest { clusterState, clock); } + @Test public void testSearchSlotSuccessful() throws Exception { expectGetPendingTasks(TASK_A, TASK_B); @@ -113,8 +112,8 @@ public class PendingTaskProcessorTest extends EasyMockTest { HostOffer offer1 = makeOffer(SLAVE_ID_1); HostOffer offer2 = makeOffer(SLAVE_ID_2); expectOffers(offer1, offer2); - expectSlotSearch(TASK_A, offer1, TASK_A); - expectSlotSearch(TASK_B, offer2, TASK_B); + expectSlotSearch(TASK_A.getAssignedTask().getTask(), TASK_A); + expectSlotSearch(TASK_B.getAssignedTask().getTask(), TASK_B); control.replay(); @@ -134,7 +133,7 @@ public class PendingTaskProcessorTest extends EasyMockTest { expectGetClusterState(TASK_A); HostOffer offer1 = makeOffer(SLAVE_ID_1); expectOffers(offer1); - expectSlotSearch(TASK_A, offer1); + expectSlotSearch(TASK_A.getAssignedTask().getTask()); control.replay(); @@ -168,11 +167,11 @@ public class PendingTaskProcessorTest extends EasyMockTest { @Test public void testMultipleTaskGroups() throws Exception { - ScheduledTask task1 = makeTask(JOB_A, "1"); - ScheduledTask task2 = makeTask(JOB_A, "2"); - ScheduledTask task3 = makeTask(JOB_A, "3"); - ScheduledTask task4 = makeTask(JOB_B, "4"); - ScheduledTask task5 = makeTask(JOB_B, "5"); + IScheduledTask task1 = makeTask(JOB_A, "1"); + IScheduledTask task2 = makeTask(JOB_A, "2"); + IScheduledTask task3 = makeTask(JOB_A, "3"); + IScheduledTask task4 = makeTask(JOB_B, "4"); + IScheduledTask task5 = makeTask(JOB_B, "5"); expectGetPendingTasks(task1, task4, task2, task5, task3); expectGetClusterState(TASK_A, TASK_B); @@ -180,9 +179,8 @@ public class PendingTaskProcessorTest extends EasyMockTest { HostOffer offer1 = makeOffer(SLAVE_ID_1); HostOffer offer2 = makeOffer(SLAVE_ID_2); expectOffers(offer1, offer2); - expectSlotSearch(task1, offer1); - expectSlotSearch(task4, offer1, TASK_B); - expectSlotSearch(task5, offer2, TASK_B); + expectSlotSearch(task1.getAssignedTask().getTask()); + expectSlotSearch(task4.getAssignedTask().getTask(), TASK_B); PreemptionProposal proposal1 = createPreemptionProposal(TASK_B, SLAVE_ID_1); PreemptionProposal proposal2 = createPreemptionProposal(TASK_B, SLAVE_ID_2); @@ -196,7 +194,7 @@ public class PendingTaskProcessorTest extends EasyMockTest { assertEquals(1L, statsProvider.getLongValue(TASK_PROCESSOR_RUN_NAME)); assertEquals(3L, statsProvider.getLongValue(attemptsStatName(true))); assertEquals(2L, statsProvider.getLongValue(slotSearchStatName(true, true))); - assertEquals(1L, statsProvider.getLongValue(slotSearchStatName(false, true))); + assertEquals(2L, statsProvider.getLongValue(slotSearchStatName(false, true))); assertEquals(2L, statsProvider.getLongValue(CACHE_STAT)); } @@ -214,23 +212,10 @@ public class PendingTaskProcessorTest extends EasyMockTest { assertEquals(0L, statsProvider.getLongValue(slotSearchStatName(false, true))); } - private static final Function<ScheduledTask, String> GET_SLAVE_ID = - new Function<ScheduledTask, String>() { - @Override - public String apply(ScheduledTask task) { - return task.getAssignedTask().getSlaveId(); - } - }; - - private Multimap<String, PreemptionVictim> getVictims(ScheduledTask... tasks) { + private Multimap<String, PreemptionVictim> getVictims(IScheduledTask... tasks) { return Multimaps.transformValues( - Multimaps.index(Arrays.asList(tasks), GET_SLAVE_ID), - new Function<ScheduledTask, PreemptionVictim>() { - @Override - public PreemptionVictim apply(ScheduledTask task) { - return PreemptionVictim.fromTask(IAssignedTask.build(task.getAssignedTask())); - } - } + Multimaps.index(Arrays.asList(tasks), task -> task.getAssignedTask().getSlaveId()), + task -> PreemptionVictim.fromTask(task.getAssignedTask()) ); } @@ -249,36 +234,39 @@ public class PendingTaskProcessorTest extends EasyMockTest { expect(offerManager.getOffers()).andReturn(ImmutableSet.copyOf(offers)); } - private void expectGetClusterState(ScheduledTask... returnedTasks) { + private void expectGetClusterState(IScheduledTask... returnedTasks) { expect(clusterState.getSlavesToActiveTasks()).andReturn(getVictims(returnedTasks)); } - private void expectSlotSearch(ScheduledTask task, HostOffer offer, ScheduledTask... victims) { + private void expectSlotSearch(ITaskConfig config, IScheduledTask... victims) { expect(preemptionVictimFilter.filterPreemptionVictims( - eq(ITaskConfig.build(task.getAssignedTask().getTask())), + eq(config), EasyMock.<Iterable<PreemptionVictim>>anyObject(), anyObject(AttributeAggregate.class), - eq(Optional.of(offer)), - eq(storageUtil.storeProvider))).andReturn( + EasyMock.<Optional<HostOffer>>anyObject(), + eq(storageUtil.storeProvider))); + expectLastCall().andReturn( victims.length == 0 ? Optional.<ImmutableSet<PreemptionVictim>>absent() - : Optional.of(ImmutableSet.copyOf(getVictims(victims).values()))); + : Optional.of(ImmutableSet.copyOf(getVictims(victims).values()))) + .anyTimes(); } - private static PreemptionProposal createPreemptionProposal(ScheduledTask task, String slaveId) { - IAssignedTask assigned = IAssignedTask.build(task.getAssignedTask()); - return new PreemptionProposal(ImmutableSet.of(PreemptionVictim.fromTask(assigned)), slaveId); + private static PreemptionProposal createPreemptionProposal(IScheduledTask task, String slaveId) { + return new PreemptionProposal( + ImmutableSet.of(PreemptionVictim.fromTask(task.getAssignedTask())), + slaveId); } - private static ScheduledTask makeTask(JobKey key, String taskId) { + private static IScheduledTask makeTask(JobKey key, String taskId) { return makeTask(key, null, taskId); } - private static TaskGroupKey group(ScheduledTask task) { - return TaskGroupKey.from(ITaskConfig.build(task.getAssignedTask().getTask())); + private static TaskGroupKey group(IScheduledTask task) { + return TaskGroupKey.from(task.getAssignedTask().getTask()); } - private static ScheduledTask makeTask(JobKey key, @Nullable String slaveId, String taskId) { + private static IScheduledTask makeTask(JobKey key, @Nullable String slaveId, String taskId) { ScheduledTask task = new ScheduledTask() .setAssignedTask(new AssignedTask() .setSlaveId(slaveId) @@ -288,12 +276,10 @@ public class PendingTaskProcessorTest extends EasyMockTest { .setProduction(true) .setJob(key))); task.addToTaskEvents(new TaskEvent(0, PENDING)); - return task; + return IScheduledTask.build(task); } - private void expectGetPendingTasks(ScheduledTask... returnedTasks) { - storageUtil.expectTaskFetch( - Query.statusScoped(PENDING), - IScheduledTask.setFromBuilders(Arrays.asList(returnedTasks))); + private void expectGetPendingTasks(IScheduledTask... returnedTasks) { + storageUtil.expectTaskFetch(Query.statusScoped(PENDING), ImmutableSet.copyOf(returnedTasks)); } } http://git-wip-us.apache.org/repos/asf/aurora/blob/be75c36f/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java b/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java index d1301e0..ba56937 100644 --- a/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java +++ b/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java @@ -138,9 +138,12 @@ public class StorageBackupTest extends EasyMockTest { assertBackupCount(MAX_BACKUPS); assertEquals(MAX_BACKUPS + 1, storageBackup.getSuccesses().get()); List<String> backupNames = nameBuilder.build(); + + File[] files = config.getDir().listFiles(); + assertNotNull(files); assertEquals( ImmutableSet.copyOf(backupNames.subList(1, backupNames.size())), - FluentIterable.from(ImmutableList.copyOf(config.getDir().listFiles())) + FluentIterable.from(ImmutableList.copyOf(files)) .transform(StorageBackupImpl.FILE_NAME) .toSet()); }
