Skip to content

Commit 02dd07a

Browse files
committed
IGNITE-4074 Refactor async (*future) operations in PlatformTarget
1 parent 255b3a3 commit 02dd07a

File tree

26 files changed

+1060
-693
lines changed

26 files changed

+1060
-693
lines changed

modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java

+74-13
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919

2020
import org.apache.ignite.IgniteCheckedException;
2121
import org.apache.ignite.IgniteLogger;
22+
import org.apache.ignite.binary.BinaryRawReader;
2223
import org.apache.ignite.internal.IgniteInternalFuture;
2324
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
2425
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
2526
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
2627
import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
2728
import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
2829
import org.apache.ignite.internal.processors.platform.utils.PlatformListenable;
30+
import org.apache.ignite.lang.IgniteFuture;
2931
import org.jetbrains.annotations.Nullable;
3032

3133
/**
@@ -244,23 +246,12 @@ public PlatformContext platformContext() {
244246

245247
/** {@inheritDoc} */
246248
@Override public void listenFuture(final long futId, int typ) throws Exception {
247-
listenFutureAndGet(futId, typ);
249+
PlatformFutureUtils.listen(platformCtx, currentFuture(), futId, typ, null, this);
248250
}
249251

250252
/** {@inheritDoc} */
251253
@Override public void listenFutureForOperation(final long futId, int typ, int opId) throws Exception {
252-
listenFutureForOperationAndGet(futId, typ, opId);
253-
}
254-
255-
/** {@inheritDoc} */
256-
@Override public PlatformListenable listenFutureAndGet(final long futId, int typ) throws Exception {
257-
return PlatformFutureUtils.listen(platformCtx, currentFuture(), futId, typ, null, this);
258-
}
259-
260-
/** {@inheritDoc} */
261-
@Override public PlatformListenable listenFutureForOperationAndGet(final long futId, int typ, int opId)
262-
throws Exception {
263-
return PlatformFutureUtils.listen(platformCtx, currentFuture(), futId, typ, futureWriter(opId), this);
254+
PlatformFutureUtils.listen(platformCtx, currentFuture(), futId, typ, futureWriter(opId), this);
264255
}
265256

266257
/**
@@ -413,4 +404,74 @@ protected Object processOutObject(int type) throws IgniteCheckedException {
413404
protected <T> T throwUnsupported(int type) throws IgniteCheckedException {
414405
throw new IgniteCheckedException("Unsupported operation type: " + type);
415406
}
407+
408+
/**
409+
* Reads future information and listens.
410+
*
411+
* @param reader Reader.
412+
* @param fut Future.
413+
* @param writer Writer.
414+
* @throws IgniteCheckedException In case of error.
415+
*/
416+
protected PlatformListenable readAndListenFuture(BinaryRawReader reader, IgniteInternalFuture fut,
417+
PlatformFutureUtils.Writer writer)
418+
throws IgniteCheckedException {
419+
long futId = reader.readLong();
420+
int futTyp = reader.readInt();
421+
422+
return PlatformFutureUtils.listen(platformCtx, fut, futId, futTyp, writer, this);
423+
}
424+
425+
/**
426+
* Reads future information and listens.
427+
*
428+
* @param reader Reader.
429+
* @param fut Future.
430+
* @param writer Writer.
431+
* @throws IgniteCheckedException In case of error.
432+
*/
433+
protected PlatformListenable readAndListenFuture(BinaryRawReader reader, IgniteFuture fut,
434+
PlatformFutureUtils.Writer writer)
435+
throws IgniteCheckedException {
436+
long futId = reader.readLong();
437+
int futTyp = reader.readInt();
438+
439+
return PlatformFutureUtils.listen(platformCtx, fut, futId, futTyp, writer, this);
440+
}
441+
442+
/**
443+
* Reads future information and listens.
444+
*
445+
* @param reader Reader.
446+
* @param fut Future.
447+
* @throws IgniteCheckedException In case of error.
448+
*/
449+
protected PlatformListenable readAndListenFuture(BinaryRawReader reader, IgniteInternalFuture fut)
450+
throws IgniteCheckedException {
451+
return readAndListenFuture(reader, fut, null);
452+
}
453+
454+
/**
455+
* Reads future information and listens.
456+
*
457+
* @param reader Reader.
458+
* @param fut Future.
459+
* @throws IgniteCheckedException In case of error.
460+
*/
461+
protected PlatformListenable readAndListenFuture(BinaryRawReader reader, IgniteFuture fut)
462+
throws IgniteCheckedException {
463+
return readAndListenFuture(reader, fut, null);
464+
}
465+
466+
/**
467+
* Reads future information and listens.
468+
*
469+
* @param reader Reader.
470+
* @throws IgniteCheckedException In case of error.
471+
*/
472+
protected long readAndListenFuture(BinaryRawReader reader) throws IgniteCheckedException {
473+
readAndListenFuture(reader, currentFuture(), null);
474+
475+
return TRUE;
476+
}
416477
}

modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java

-21
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,4 @@ public Object inObjectStreamOutObjectStream(int type, @Nullable Object arg, long
137137
*/
138138
@SuppressWarnings("UnusedDeclaration")
139139
public void listenFutureForOperation(final long futId, int typ, int opId) throws Exception;
140-
141-
/**
142-
* Start listening for the future.
143-
*
144-
* @param futId Future ID.
145-
* @param typ Result type.
146-
* @throws IgniteCheckedException In case of failure.
147-
*/
148-
@SuppressWarnings("UnusedDeclaration")
149-
public PlatformListenable listenFutureAndGet(final long futId, int typ) throws Exception;
150-
151-
/**
152-
* Start listening for the future for specific operation type.
153-
*
154-
* @param futId Future ID.
155-
* @param typ Result type.
156-
* @param opId Operation ID required to pick correct result writer.
157-
* @throws IgniteCheckedException In case of failure.
158-
*/
159-
@SuppressWarnings("UnusedDeclaration")
160-
public PlatformListenable listenFutureForOperationAndGet(final long futId, int typ, int opId) throws Exception;
161140
}

0 commit comments

Comments
 (0)