forked from Alluxio/alluxio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4206be
commit 9e2648e
Showing
12 changed files
with
637 additions
and
72 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
dora/core/common/src/main/java/alluxio/util/io/ByteBufferInputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package alluxio.util.io; | ||
|
||
import com.google.common.base.Preconditions; | ||
import io.netty.buffer.ByteBufInputStream; | ||
import io.netty.buffer.ByteBufOutputStream; | ||
import io.netty.buffer.Unpooled; | ||
import jdk.internal.util.xml.impl.Input; | ||
|
||
import java.io.DataInput; | ||
import java.io.DataInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.nio.BufferOverflowException; | ||
import java.nio.BufferUnderflowException; | ||
import java.nio.ByteBuffer; | ||
import java.nio.ReadOnlyBufferException; | ||
|
||
public class ByteBufferInputStream extends DataInputStream { | ||
private final InternalInputStream mInternalInputStream; | ||
|
||
public static class InternalInputStream extends InputStream { | ||
private final ByteBuffer mBuffer; | ||
|
||
public InternalInputStream(ByteBuffer buffer) { | ||
Preconditions.checkArgument(buffer.isDirect(), "Input bytebuffer must be direct."); | ||
mBuffer = buffer.duplicate(); | ||
} | ||
|
||
@Override | ||
public int read() throws IOException { | ||
try { | ||
return mBuffer.get(); | ||
} catch (BufferUnderflowException ex) { | ||
throw new IOException(ex); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
// DO NOTHING | ||
} | ||
} | ||
|
||
public static ByteBufferInputStream getInputStream(ByteBuffer buffer) { | ||
InternalInputStream internalIs = new InternalInputStream(buffer); | ||
return new ByteBufferInputStream(internalIs); | ||
} | ||
|
||
public ByteBufferInputStream(InternalInputStream internalIs) { | ||
super(internalIs); | ||
mInternalInputStream = internalIs; | ||
} | ||
|
||
public void read(ByteBuffer targetBuffer, int len) throws IOException { | ||
if (targetBuffer.remaining() < len) { | ||
throw new IOException("Not enough space left in targetBuffer to fill " + len + " bytes"); | ||
} | ||
for (int i = 0; i < len; i++) { | ||
targetBuffer.put((byte)super.read()); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
super.close(); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
dora/core/common/src/main/java/alluxio/util/io/ByteBufferOutputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package alluxio.util.io; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.nio.BufferOverflowException; | ||
import java.nio.ByteBuffer; | ||
import java.nio.ReadOnlyBufferException; | ||
|
||
public class ByteBufferOutputStream extends DataOutputStream { | ||
|
||
public static class InternalOutputStream extends OutputStream { | ||
private final ByteBuffer mBuffer; | ||
|
||
public InternalOutputStream(ByteBuffer buffer) { | ||
Preconditions.checkArgument(buffer.isDirect(), "Input bytebuffer must be direct."); | ||
mBuffer = buffer.duplicate(); | ||
} | ||
|
||
@Override | ||
public void write(int b) throws IOException { | ||
try { | ||
mBuffer.put((byte) b); | ||
} catch (BufferOverflowException | ReadOnlyBufferException ex) { | ||
throw new IOException(ex); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
// DO NOTHING | ||
} | ||
} | ||
|
||
/** | ||
* Assumption here is this buffer got its writable window adjusted already | ||
* when calling this func. | ||
* @param buffer | ||
* @return | ||
*/ | ||
public static ByteBufferOutputStream getOutputStream(ByteBuffer buffer) { | ||
ByteBufferOutputStream.InternalOutputStream internalOs = | ||
new ByteBufferOutputStream.InternalOutputStream(buffer); | ||
return new ByteBufferOutputStream(internalOs); | ||
} | ||
|
||
public ByteBufferOutputStream(ByteBufferOutputStream.InternalOutputStream internalOs) { | ||
super(internalOs); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
super.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
digraph G { | ||
CREATED -> READING_DATA [label = "START" ]; | ||
TERMINATED_NORMALLY -> COMPLETED [label = "END" ]; | ||
TERMINATED_NORMALLY -> TERMINATED_EXCEPTIONALLY [label = "COMPLETE_REQUEST_ERROR" ]; | ||
READING_DATA -> SENDING_DATA [label = "SEND_DATA_AFTER_READING" ]; | ||
READING_DATA -> TERMINATED_EXCEPTIONALLY [label = "SEND_DATA_ERROR" ]; | ||
READING_DATA -> TERMINATED_EXCEPTIONALLY [label = "CHANNEL_EXCEPTION" ]; | ||
READING_DATA -> TERMINATED_NORMALLY [label = "CANCELLED" ]; | ||
READING_DATA -> TERMINATED_EXCEPTIONALLY [label = "READ_DATA_ERROR" ]; | ||
TERMINATED_EXCEPTIONALLY -> COMPLETED [label = "END" ]; | ||
SENDING_DATA -> TERMINATED_EXCEPTIONALLY [label = "SEND_DATA_ERROR" ]; | ||
SENDING_DATA -> TERMINATED_EXCEPTIONALLY [label = "CHANNEL_EXCEPTION" ]; | ||
SENDING_DATA -> TERMINATED_NORMALLY [label = "OUTPUT_LENGTH_FULFILLED" ]; | ||
SENDING_DATA -> TERMINATED_NORMALLY [label = "CANCELLED" ]; | ||
SENDING_DATA -> READING_DATA [label = "OUTPUT_LENGTH_NOT_FULFILLED" ]; | ||
} |
23 changes: 23 additions & 0 deletions
23
dora/core/server/worker/src/main/java/alluxio/worker/ucx/AlluxioUcxUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package alluxio.worker.ucx; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import org.openucx.jucx.ucp.UcpWorker; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
public class AlluxioUcxUtils { | ||
public static final int METADATA_SIZE_COMMON = 4096; | ||
|
||
public static void writeConnectionMetadata( | ||
ByteBuffer targetBuffer, | ||
long tagForRemote, UcpWorker localWorker) { | ||
// long (tag assigned to remote) | int (worker addr size) | bytes (worker addr) | ||
// we allocate the common metadata size to match the send/recv tag exchange size | ||
targetBuffer.putLong(tagForRemote); | ||
ByteBuffer localWorkerAddr = localWorker.getAddress(); | ||
targetBuffer.putInt(localWorkerAddr.capacity()); // UcpWorer.getAddress always return a buffer with full capacity filled | ||
targetBuffer.put(localWorkerAddr); | ||
targetBuffer.clear(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
dora/core/server/worker/src/main/java/alluxio/worker/ucx/ReadRequestRMAHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package alluxio.worker.ucx; | ||
|
||
import org.openucx.jucx.ucp.UcpEndpoint; | ||
|
||
public class ReadRequestRMAHandler implements UcxRequestHandler { | ||
|
||
@Override | ||
public void handle(UcxMessage message, UcpEndpoint endpoint) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
dora/core/server/worker/src/main/java/alluxio/worker/ucx/Stage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package alluxio.worker.ucx; | ||
|
||
import java.util.concurrent.BlockingQueue; | ||
import java.util.concurrent.RejectedExecutionHandler; | ||
import java.util.concurrent.ThreadFactory; | ||
import java.util.concurrent.ThreadPoolExecutor; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class Stage { | ||
private final ThreadPoolExecutor mInternalThreadPool = null; | ||
|
||
public Stage(String stageName, | ||
int corePoolSize, | ||
int maximumPoolSize, | ||
ThreadFactory threadFactory, | ||
BlockingQueue<Runnable> workQueue, | ||
RejectedExecutionHandler handler) { | ||
|
||
|
||
} | ||
|
||
} |
Oops, something went wrong.