Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,24 @@ public static synchronized ComputerOptions instance() {
positiveInt(),
TimeUnit.SECONDS.toMillis(30L)
);

public static final ConfigOption<Integer> WORKER_DATA_PORT_START =
new ConfigOption<>(
"worker.data_port_start",
"The start of range [data_port_start, data_port_end]. " +
"The worker will choose one from small to large of the " +
"range for data transportation.",
positiveInt(),
11000
);

public static final ConfigOption<Integer> WORKER_DATA_PORT_END =
new ConfigOption<>(
"worker.data_port_end",
"The end of range [data_port_start, data_port_end]. " +
"The worker will choose one from small to large of the " +
"range for data transportation.",
positiveInt(),
12000
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2017 HugeGraph Authors
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

package com.baidu.hugegraph.computer.core.network;

import java.nio.ByteBuffer;

public interface MessageHandler {

/**
* Handle the buffer received. There are two buffer list for a partition,
* one for sorting and one for receiving new buffers. It may block the
* caller if the receiving list reached threshold and the sorting list is
* sorting in process.
*/
void handle(byte messageType, int partition, ByteBuffer buffer);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2017 HugeGraph Authors
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

package com.baidu.hugegraph.computer.core.network;

import java.io.IOException;

import com.baidu.hugegraph.computer.core.config.Config;

import io.netty.buffer.ByteBuf;

/**
* This is used for worker to send buffer to other worker. The whole process
* contains several iteration. In one iteration {@link #startSession} is
* called only once. {@link #send} is called zero or more times.
* {@link #finishSession()} is called only once.
*/
public interface Transport4Client {

/**
* Init the connection from client to server. This method is called only
* once. MAX_PENDING_REQUESTS is set in config
* @throws IOException if can't create connection.
*/
void init(Config config, String hostname, int port) throws IOException;

/**
* This method is called before an iteration of sending buffers.
*/
void startSession();

/**
* Send the buffer to the server. Block the caller if busy.
* This method is called zero or many times in iteration.
* @throws IOException if failed, the job will fail.
*/
void send(byte messageType, int partition, ByteBuf buffer)
throws IOException;

/**
* This method is called after an iteration. It will block the caller to
* make sure the buffers sent be received by target workers.
*/
void finishSession() throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2017 HugeGraph Authors
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

package com.baidu.hugegraph.computer.core.network;

import com.baidu.hugegraph.computer.core.config.Config;

/**
* This is used for worker that receives data.
*/
public interface Transport4Server {

/**
* Startup server, return the port listened. The port range in config is
* [{@link @ComputerOptions.WORKER_DATA_PORT_START #STATIC_FIELD},
* {@link @ComputerOptions.WORKER_DATA_PORT_END #STATIC_FIELD}].
*/
int listen(Config config, MessageHandler handler);

Copy link
Contributor

Choose a reason for hiding this comment

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

add pauseReceive() and resumeReceive()
if the pending_messages feature can control flow rate, we can delete ignore-resume

Copy link
Contributor Author

Choose a reason for hiding this comment

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

listen, set the port range in config.

/**
* Stop the server
*/
void stop();
}