Skip to content

Conversation

@sundargates
Copy link
Contributor

Context

Before both the APIs were not available, we would get rid of the container as part of shutting down the workload. In the new Titus world, we want to gracefully shut down all the resources associated with the stage execution.

Checklist

  • ./gradlew build compiles code correctly
  • Added new tests where applicable
  • ./gradlew test passes all tests
  • Extended README or added javadocs where applicable
  • Added copyright headers for new files from CONTRIBUTING.md

@sundargates
Copy link
Contributor Author

Only the last commit in this diff needs to be reviewed. It's stacked on top of Part 11.

@SuppressWarnings( {"rawtypes", "unchecked"})
@Override
public void start(final StageConfig<T, R> stage, Observable<Observable<R>> toServe) {
public void start(final StageConfig<?, T> stage, Observable<Observable<T>> toServe) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting change, wasn't expecting it.
LGTM but would appreciate a closer look from one more person here. perhaps @codyrioux or @Andyz26

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just took a look through and this appears to be fine. I like that it is more explicit about the fact that we are not using the first type parameter in the StageConfig in these locations.

Copy link
Contributor

@codyrioux codyrioux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate that you took the time to leverage functional features and get rid of the ad-hoc interface implementations.

Before both the APIs were not available, we would get rid of the container as part of shutting down the workload. In the new Titus world, we want to gracefully shut down all the resources associated with the stage execution.
@sundargates sundargates force-pushed the sundaram/titus_part12 branch from 9d9819e to 5d380c1 Compare April 6, 2022 17:55
public class SinkPublisher<T, R> implements WorkerPublisher<T, R> {
/**
* Implementation that publishes the results of a stage to a sink such as an SSE port.
* @param <T>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

private final Action0 onUnsubscribeAction;
private final Action0 observableOnCompleteCallback;
private final Action1<Throwable> observableOnErrorCallback;
private Subscription eagerSubscription;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: separate the state from the rest of the fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

} finally {
if (eagerSubscription != null) {
eagerSubscription.unsubscribe();
eagerSubscription = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should sink also be set to null eventually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.


@Override
public void stop() {}
public void close() throws IOException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there nothing to close for this executor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing the Observable handles most of the behavior under the hood when the unsubscribe occurs. Or just depends on the whole JVM being blown away.

private int serverPort;
private final String name;
private final int serverPort;
private RemoteRxServer server;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate state from the fields


@Override
public void close() throws IOException {
if (future != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reset the state in the finally block to make close() idempotent


@Override
public void close() throws IOException {
executor.shutdownNow();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set executor to null

String locateSpectatorRegistry =
ServiceRegistry.INSTANCE.getPropertiesService().getStringValue("mantis.worker.locate.spectator.registry", "true");
lookupSpectatorRegistry = Boolean.valueOf(locateSpectatorRegistry);
scheduledExecutorService = new ScheduledThreadPoolExecutor(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name the thread pool factory please.


@Override
public void shutdownStage() {
public void shutdownStage() throws IOException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure shutdownStage cannot be called when executeStage is being executed.

}

System.exit(0);
Closeables.combine(closeables).close();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean the closeables to make this idempotent.


@Override
public void stop() {}
public void close() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing the Observable handles most of the behavior under the hood when the unsubscribe occurs. Or just depends on the whole JVM being blown away.

@sundargates sundargates merged commit d8c82e1 into Netflix:master Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants