Repository: aurora Updated Branches: refs/heads/master 24d2cafaa -> 6fd6d5028
Replace auto-generated forwarding code with manual implementations Reviewed at https://reviews.apache.org/r/62716/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/6fd6d502 Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/6fd6d502 Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/6fd6d502 Branch: refs/heads/master Commit: 6fd6d50288d6155fda212cecab539c5fb669a9aa Parents: 24d2caf Author: Bill Farner <[email protected]> Authored: Sun Oct 1 08:49:06 2017 -0700 Committer: Bill Farner <[email protected]> Committed: Sun Oct 1 08:49:06 2017 -0700 ---------------------------------------------------------------------- build.gradle | 1 - .../storage/log/WriteAheadStorage.java | 129 +++++++-- .../thrift/aop/MockDecoratedThrift.java | 260 ++++++++++++++++++- 3 files changed, 364 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/6fd6d502/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index f9579a3..069c62e 100644 --- a/build.gradle +++ b/build.gradle @@ -428,7 +428,6 @@ dependencies { compile 'org.mybatis:mybatis-guice:3.7' compile 'org.mybatis:mybatis-migrations:3.2.0' compile 'org.quartz-scheduler:quartz:2.2.2' - compile "uno.perk:forward:1.0.0" testCompile "com.sun.jersey:jersey-client:${jerseyRev}" testCompile "junit:junit:${junitRev}" http://git-wip-us.apache.org/repos/asf/aurora/blob/6fd6d502/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java b/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java index 325d3a1..d145259 100644 --- a/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java +++ b/src/main/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorage.java @@ -13,6 +13,8 @@ */ package org.apache.aurora.scheduler.storage.log; +import java.util.List; +import java.util.Map; import java.util.Set; import com.google.common.base.Function; @@ -35,6 +37,8 @@ import org.apache.aurora.gen.storage.SaveJobUpdateEvent; import org.apache.aurora.gen.storage.SaveLock; import org.apache.aurora.gen.storage.SaveQuota; import org.apache.aurora.gen.storage.SaveTasks; +import org.apache.aurora.gen.storage.StoredJobUpdateDetails; +import org.apache.aurora.scheduler.base.Query; import org.apache.aurora.scheduler.events.EventSink; import org.apache.aurora.scheduler.events.PubsubEvent; import org.apache.aurora.scheduler.storage.AttributeStore; @@ -50,16 +54,18 @@ import org.apache.aurora.scheduler.storage.entities.IJobConfiguration; import org.apache.aurora.scheduler.storage.entities.IJobInstanceUpdateEvent; import org.apache.aurora.scheduler.storage.entities.IJobKey; import org.apache.aurora.scheduler.storage.entities.IJobUpdate; +import org.apache.aurora.scheduler.storage.entities.IJobUpdateDetails; import org.apache.aurora.scheduler.storage.entities.IJobUpdateEvent; +import org.apache.aurora.scheduler.storage.entities.IJobUpdateInstructions; import org.apache.aurora.scheduler.storage.entities.IJobUpdateKey; +import org.apache.aurora.scheduler.storage.entities.IJobUpdateQuery; +import org.apache.aurora.scheduler.storage.entities.IJobUpdateSummary; import org.apache.aurora.scheduler.storage.entities.ILock; import org.apache.aurora.scheduler.storage.entities.ILockKey; import org.apache.aurora.scheduler.storage.entities.IResourceAggregate; import org.apache.aurora.scheduler.storage.entities.IScheduledTask; import org.slf4j.Logger; -import uno.perk.forward.Forward; - import static java.util.Objects.requireNonNull; import static org.apache.aurora.scheduler.storage.log.LogStorage.TransactionManager; @@ -69,15 +75,7 @@ import static org.apache.aurora.scheduler.storage.log.LogStorage.TransactionMana * to a provided {@link TransactionManager}) before forwarding the operations to delegate mutable * stores. */ -@Forward({ - SchedulerStore.class, - CronJobStore.class, - TaskStore.class, - LockStore.class, - QuotaStore.class, - AttributeStore.class, - JobUpdateStore.class}) -class WriteAheadStorage extends WriteAheadStorageForwarder implements +class WriteAheadStorage implements MutableStoreProvider, SchedulerStore.Mutable, CronJobStore.Mutable, @@ -122,15 +120,6 @@ class WriteAheadStorage extends WriteAheadStorageForwarder implements Logger log, EventSink eventSink) { - super( - schedulerStore, - jobStore, - taskStore, - lockStore, - quotaStore, - attributeStore, - jobUpdateStore); - this.transactionManager = requireNonNull(transactionManager); this.schedulerStore = requireNonNull(schedulerStore); this.jobStore = requireNonNull(jobStore); @@ -373,4 +362,104 @@ class WriteAheadStorage extends WriteAheadStorageForwarder implements throw new UnsupportedOperationException( "Unsupported since casual storage users should never be doing this."); } + + @Override + public Optional<String> fetchFrameworkId() { + return this.schedulerStore.fetchFrameworkId(); + } + + @Override + public Iterable<IJobConfiguration> fetchJobs() { + return this.jobStore.fetchJobs(); + } + + @Override + public Optional<IJobConfiguration> fetchJob(IJobKey jobKey) { + return this.jobStore.fetchJob(jobKey); + } + + @Override + public Optional<IScheduledTask> fetchTask(String taskId) { + return this.taskStore.fetchTask(taskId); + } + + @Override + public Iterable<IScheduledTask> fetchTasks(Query.Builder query) { + return this.taskStore.fetchTasks(query); + } + + @Override + public Set<IJobKey> getJobKeys() { + return this.taskStore.getJobKeys(); + } + + @Override + public Optional<IResourceAggregate> fetchQuota(String role) { + return this.quotaStore.fetchQuota(role); + } + + @Override + public Map<String, IResourceAggregate> fetchQuotas() { + return this.quotaStore.fetchQuotas(); + } + + @Override + public Set<ILock> fetchLocks() { + return this.lockStore.fetchLocks(); + } + + @Override + public java.util.Optional<ILock> fetchLock(ILockKey lockKey) { + return this.lockStore.fetchLock(lockKey); + } + + @Override + public Optional<IHostAttributes> getHostAttributes(String host) { + return this.attributeStore.getHostAttributes(host); + } + + @Override + public Set<IHostAttributes> getHostAttributes() { + return this.attributeStore.getHostAttributes(); + } + + @Override + public List<IJobUpdateSummary> fetchJobUpdateSummaries(IJobUpdateQuery query) { + return this.jobUpdateStore.fetchJobUpdateSummaries(query); + } + + @Override + public List<IJobUpdateDetails> fetchJobUpdateDetails(IJobUpdateQuery query) { + return this.jobUpdateStore.fetchJobUpdateDetails(query); + } + + @Override + public Optional<IJobUpdateDetails> fetchJobUpdateDetails(IJobUpdateKey key) { + return this.jobUpdateStore.fetchJobUpdateDetails(key); + } + + @Override + public Optional<IJobUpdate> fetchJobUpdate(IJobUpdateKey key) { + return this.jobUpdateStore.fetchJobUpdate(key); + } + + @Override + public Optional<IJobUpdateInstructions> fetchJobUpdateInstructions(IJobUpdateKey key) { + return this.jobUpdateStore.fetchJobUpdateInstructions(key); + } + + @Override + public Set<StoredJobUpdateDetails> fetchAllJobUpdateDetails() { + return this.jobUpdateStore.fetchAllJobUpdateDetails(); + } + + @Override + public List<IJobInstanceUpdateEvent> fetchInstanceEvents(IJobUpdateKey key, int instanceId) { + return this.jobUpdateStore.fetchInstanceEvents(key, instanceId); + } + + @Override + public Optional<String> getLockToken(IJobUpdateKey key) { + return this.jobUpdateStore.getLockToken(key); + } } http://git-wip-us.apache.org/repos/asf/aurora/blob/6fd6d502/src/test/java/org/apache/aurora/scheduler/thrift/aop/MockDecoratedThrift.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/aop/MockDecoratedThrift.java b/src/test/java/org/apache/aurora/scheduler/thrift/aop/MockDecoratedThrift.java index 0547b1a..d412090 100644 --- a/src/test/java/org/apache/aurora/scheduler/thrift/aop/MockDecoratedThrift.java +++ b/src/test/java/org/apache/aurora/scheduler/thrift/aop/MockDecoratedThrift.java @@ -17,6 +17,7 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.util.Set; import javax.inject.Inject; import javax.inject.Qualifier; @@ -24,9 +25,21 @@ import javax.inject.Qualifier; import com.google.inject.Binder; import org.apache.aurora.gen.AuroraAdmin; +import org.apache.aurora.gen.ExplicitReconciliationSettings; +import org.apache.aurora.gen.Hosts; +import org.apache.aurora.gen.InstanceKey; +import org.apache.aurora.gen.JobConfiguration; +import org.apache.aurora.gen.JobKey; +import org.apache.aurora.gen.JobUpdateKey; +import org.apache.aurora.gen.JobUpdateQuery; +import org.apache.aurora.gen.JobUpdateRequest; +import org.apache.aurora.gen.ResourceAggregate; +import org.apache.aurora.gen.Response; +import org.apache.aurora.gen.ScheduleStatus; +import org.apache.aurora.gen.TaskQuery; +import org.apache.aurora.scheduler.http.api.security.AuthorizingParam; import org.apache.aurora.scheduler.thrift.auth.DecoratedThrift; - -import uno.perk.forward.Forward; +import org.apache.thrift.TException; /** * An injected forwarding thrift implementation that delegates to a bound mock interface. @@ -35,17 +48,18 @@ import uno.perk.forward.Forward; * https://code.google.com/p/google-guice/wiki/AOP#Limitations */ @DecoratedThrift -@Forward(AnnotatedAuroraAdmin.class) -public class MockDecoratedThrift extends MockDecoratedThriftForwarder { +public class MockDecoratedThrift implements AnnotatedAuroraAdmin { @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.PARAMETER, ElementType.METHOD}) @Qualifier private @interface MockThrift { } + private final AnnotatedAuroraAdmin annotatedAuroraAdmin; + @Inject MockDecoratedThrift(@MockThrift AnnotatedAuroraAdmin delegate) { - super(delegate); + this.annotatedAuroraAdmin = delegate; } public static void bindForwardedMock(Binder binder, AnnotatedAuroraAdmin mockThrift) { @@ -54,4 +68,240 @@ public class MockDecoratedThrift extends MockDecoratedThriftForwarder { binder.bind(AnnotatedAuroraAdmin.class).to(MockDecoratedThrift.class); binder.bind(AuroraAdmin.Iface.class).to(MockDecoratedThrift.class); } + + @Override + public Response getRoleSummary() throws TException { + return this.annotatedAuroraAdmin.getRoleSummary(); + } + + @Override + public Response getJobSummary(String role) throws TException { + return this.annotatedAuroraAdmin.getJobSummary(role); + } + + @Override + public Response getTasksStatus(TaskQuery query) throws TException { + return this.annotatedAuroraAdmin.getTasksStatus(query); + } + + @Override + public Response getTasksWithoutConfigs(TaskQuery query) throws TException { + return this.annotatedAuroraAdmin.getTasksWithoutConfigs(query); + } + + @Override + public Response getPendingReason(TaskQuery query) throws TException { + return this.annotatedAuroraAdmin.getPendingReason(query); + } + + @Override + public Response getConfigSummary(JobKey job) throws TException { + return this.annotatedAuroraAdmin.getConfigSummary(job); + } + + @Override + public Response getJobs(String ownerRole) throws TException { + return this.annotatedAuroraAdmin.getJobs(ownerRole); + } + + @Override + public Response getQuota(String ownerRole) throws TException { + return this.annotatedAuroraAdmin.getQuota(ownerRole); + } + + @Override + public Response populateJobConfig(JobConfiguration description) throws TException { + return this.annotatedAuroraAdmin.populateJobConfig(description); + } + + @Override + public Response getJobUpdateSummaries(JobUpdateQuery jobUpdateQuery) throws TException { + return this.annotatedAuroraAdmin.getJobUpdateSummaries(jobUpdateQuery); + } + + @Override + public Response getJobUpdateDetails(JobUpdateKey key, JobUpdateQuery query) throws TException { + return this.annotatedAuroraAdmin.getJobUpdateDetails(key, query); + } + + @Override + public Response getJobUpdateDiff(JobUpdateRequest request) throws TException { + return this.annotatedAuroraAdmin.getJobUpdateDiff(request); + } + + @Override + public Response getTierConfigs() throws TException { + return this.annotatedAuroraAdmin.getTierConfigs(); + } + + @Override + public Response setQuota(String ownerRole, ResourceAggregate quota) throws TException { + return this.annotatedAuroraAdmin.setQuota(ownerRole, quota); + } + + @Override + public Response forceTaskState(String taskId, ScheduleStatus status) throws TException { + return this.annotatedAuroraAdmin.forceTaskState(taskId, status); + } + + @Override + public Response performBackup() throws TException { + return this.annotatedAuroraAdmin.performBackup(); + } + + @Override + public Response listBackups() throws TException { + return this.annotatedAuroraAdmin.listBackups(); + } + + @Override + public Response stageRecovery(String backupId) throws TException { + return this.annotatedAuroraAdmin.stageRecovery(backupId); + } + + @Override + public Response queryRecovery(TaskQuery query) throws TException { + return this.annotatedAuroraAdmin.queryRecovery(query); + } + + @Override + public Response deleteRecoveryTasks(TaskQuery query) throws TException { + return this.annotatedAuroraAdmin.deleteRecoveryTasks(query); + } + + @Override + public Response commitRecovery() throws TException { + return this.annotatedAuroraAdmin.commitRecovery(); + } + + @Override + public Response unloadRecovery() throws TException { + return this.annotatedAuroraAdmin.unloadRecovery(); + } + + @Override + public Response startMaintenance(Hosts hosts) throws TException { + return this.annotatedAuroraAdmin.startMaintenance(hosts); + } + + @Override + public Response drainHosts(Hosts hosts) throws TException { + return this.annotatedAuroraAdmin.drainHosts(hosts); + } + + @Override + public Response maintenanceStatus(Hosts hosts) throws TException { + return this.annotatedAuroraAdmin.maintenanceStatus(hosts); + } + + @Override + public Response endMaintenance(Hosts hosts) throws TException { + return this.annotatedAuroraAdmin.endMaintenance(hosts); + } + + @Override + public Response snapshot() throws TException { + return this.annotatedAuroraAdmin.snapshot(); + } + + @Override + public Response triggerExplicitTaskReconciliation(ExplicitReconciliationSettings settings) + throws TException { + + return this.annotatedAuroraAdmin.triggerExplicitTaskReconciliation(settings); + } + + @Override + public Response triggerImplicitTaskReconciliation() throws TException { + return this.annotatedAuroraAdmin.triggerImplicitTaskReconciliation(); + } + + @Override + public Response pruneTasks(TaskQuery query) throws TException { + return this.annotatedAuroraAdmin.pruneTasks(query); + } + + @Override + public Response createJob(@AuthorizingParam JobConfiguration arg0) throws TException { + return this.annotatedAuroraAdmin.createJob(arg0); + } + + @Override + public Response scheduleCronJob(@AuthorizingParam JobConfiguration arg0) throws TException { + return this.annotatedAuroraAdmin.scheduleCronJob(arg0); + } + + @Override + public Response descheduleCronJob(@AuthorizingParam JobKey arg0) throws TException { + return this.annotatedAuroraAdmin.descheduleCronJob(arg0); + } + + @Override + public Response startCronJob(@AuthorizingParam JobKey arg0) throws TException { + return this.annotatedAuroraAdmin.startCronJob(arg0); + } + + @Override + public Response restartShards(@AuthorizingParam JobKey arg0, Set<Integer> arg1) + throws TException { + + return this.annotatedAuroraAdmin.restartShards(arg0, arg1); + } + + @Override + public Response killTasks(@AuthorizingParam JobKey arg0, Set<Integer> arg1, String arg2) + throws TException { + + return this.annotatedAuroraAdmin.killTasks(arg0, arg1, arg2); + } + + @Override + public Response addInstances(@AuthorizingParam InstanceKey arg0, int arg1) throws TException { + return this.annotatedAuroraAdmin.addInstances(arg0, arg1); + } + + @Override + public Response replaceCronTemplate(@AuthorizingParam JobConfiguration arg0) throws TException { + return this.annotatedAuroraAdmin.replaceCronTemplate(arg0); + } + + @Override + public Response startJobUpdate(@AuthorizingParam JobUpdateRequest arg0, String arg1) + throws TException { + + return this.annotatedAuroraAdmin.startJobUpdate(arg0, arg1); + } + + @Override + public Response pauseJobUpdate(@AuthorizingParam JobUpdateKey arg0, String arg1) + throws TException { + + return this.annotatedAuroraAdmin.pauseJobUpdate(arg0, arg1); + } + + @Override + public Response resumeJobUpdate(@AuthorizingParam JobUpdateKey arg0, String arg1) + throws TException { + + return this.annotatedAuroraAdmin.resumeJobUpdate(arg0, arg1); + } + + @Override + public Response abortJobUpdate(@AuthorizingParam JobUpdateKey arg0, String arg1) + throws TException { + + return this.annotatedAuroraAdmin.abortJobUpdate(arg0, arg1); + } + + @Override + public Response pulseJobUpdate(@AuthorizingParam JobUpdateKey arg0) throws TException { + return this.annotatedAuroraAdmin.pulseJobUpdate(arg0); + } + + @Override + public Response rollbackJobUpdate(@AuthorizingParam JobUpdateKey arg0, String arg1) + throws TException { + + return this.annotatedAuroraAdmin.rollbackJobUpdate(arg0, arg1); + } }
