proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/subscriptions/CTrieSubscriptionDirectory.java | CTrieSubscriptionDirectory | init | class CTrieSubscriptionDirectory implements ISubscriptionsDirectory {
private static final Logger LOG = LoggerFactory.getLogger(CTrieSubscriptionDirectory.class);
private CTrie ctrie;
private volatile ISubscriptionsRepository subscriptionsRepository;
private final ConcurrentMap<String, List<SharedSub... |
LOG.info("Initializing CTrie");
ctrie = new CTrie();
LOG.info("Initializing subscriptions store...");
this.subscriptionsRepository = subscriptionsRepository;
// reload any subscriptions persisted
if (LOG.isTraceEnabled()) {
LOG.trace("Reloading all stored su... | 1,732 | 294 | 2,026 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/subscriptions/DumpTreeVisitor.java | DumpTreeVisitor | prettySubscriptions | class DumpTreeVisitor implements CTrie.IVisitor<String> {
String s = "";
@Override
public void visit(CNode node, int deep) {
String indentTabs = indentTabs(deep);
s += indentTabs + (node.getToken() == null ? "''" : node.getToken().toString()) + prettySubscriptions(node) + "\n";
}
... |
if (node instanceof TNode) {
return "TNode";
}
if (node.subscriptions().isEmpty()) {
return StringUtil.EMPTY_STRING;
}
StringBuilder subScriptionsStr = new StringBuilder(" ~~[");
int counter = 0;
for (Subscription couple : node.subscriptio... | 245 | 205 | 450 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/subscriptions/ShareName.java | ShareName | equals | class ShareName {
private final String shareName;
public ShareName(String shareName) {
this.shareName = shareName;
}
@Override
public boolean equals(Object o) {<FILL_FUNCTION_BODY>}
public String getShareName() {
return shareName;
}
@Override
public int hashCode()... |
if (this == o) return true;
if (o == null) return false;
if (o instanceof String) {
return Objects.equals(shareName, (String) o);
}
if (getClass() != o.getClass()) return false;
ShareName shareName1 = (ShareName) o;
return Objects.equals(shareName, sh... | 156 | 102 | 258 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/subscriptions/SharedSubscription.java | SharedSubscription | equals | class SharedSubscription implements Comparable<SharedSubscription> {
private final ShareName shareName;
private final Topic topicFilter;
private final String clientId;
private final MqttSubscriptionOption option;
private final Optional<SubscriptionIdentifier> subscriptionId;
public SharedSubscr... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SharedSubscription that = (SharedSubscription) o;
return Objects.equals(shareName, that.shareName) &&
Objects.equals(topicFilter, that.topicFilter) &&
Objects.equals(clientId, ... | 650 | 112 | 762 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/subscriptions/Subscription.java | Subscription | equals | class Subscription implements Serializable, Comparable<Subscription>{
private static final long serialVersionUID = -3383457629635732794L;
private final MqttSubscriptionOption option;
final String clientId;
final Topic topicFilter;
final String shareName;
private final Optional<SubscriptionIden... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Subscription that = (Subscription) o;
return Objects.equals(clientId, that.clientId) &&
Objects.equals(shareName, that.shareName) &&
Objects.equals(topicFilter, that.topicFilte... | 937 | 95 | 1,032 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/subscriptions/SubscriptionIdentifier.java | SubscriptionIdentifier | equals | class SubscriptionIdentifier {
private final int subscriptionId;
public SubscriptionIdentifier(int value) {
if (value <= 0 || value > 268435455) {
throw new IllegalArgumentException("Value MUST be > 0 and <= 268435455");
}
subscriptionId = value;
}
public int value(... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SubscriptionIdentifier that = (SubscriptionIdentifier) o;
return subscriptionId == that.subscriptionId;
| 188 | 61 | 249 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/subscriptions/Token.java | Token | equals | class Token implements Comparable<Token> {
static final Token EMPTY = new Token("");
static final Token MULTI = new Token("#");
static final Token SINGLE = new Token("+");
final String name;
protected Token(String s) {
name = s;
}
protected String name() {
return name;
... |
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Token other = (Token) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
r... | 338 | 100 | 438 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/subscriptions/Topic.java | Topic | isEmpty | class Topic implements Serializable, Comparable<Topic> {
private static final Logger LOG = LoggerFactory.getLogger(Topic.class);
private static final long serialVersionUID = 2438799283749822L;
private final String topic;
private transient List<Token> tokens;
private transient boolean valid;
... |
final List<Token> tokens = getTokens();
return tokens == null || tokens.isEmpty();
| 1,616 | 27 | 1,643 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/unsafequeues/PagedFilesAllocator.java | PagedFilesAllocator | openRWPageFile | class PagedFilesAllocator implements SegmentAllocator {
interface AllocationListener {
void segmentedCreated(String name, Segment segment);
}
private final Path pagesFolder;
private final int pageSize;
private final int segmentSize;
private int lastSegmentAllocated;
private int las... |
final Path pageFile = pagesFolder.resolve(String.format("%d.page", pageId));
boolean createNew = false;
if (!Files.exists(pageFile)) {
try {
pageFile.toFile().createNewFile();
createNew = true;
} catch (IOException ex) {
th... | 775 | 291 | 1,066 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/unsafequeues/Segment.java | Segment | checkContentStartWith | class Segment {
private static final Logger LOG = LoggerFactory.getLogger(Segment.class);
final int segmentSize;
final SegmentPointer begin;
final SegmentPointer end;
private final MappedByteBuffer mappedBuffer;
Segment(MappedByteBuffer page, SegmentPointer begin, SegmentPointer end) {
... |
if (content.get(0) == 0 && content.get(1) == 0 && content.get(2) == 0 && content.get(3) == 0) {
System.out.println("DNADBG content starts with 4 zero");
}
| 1,457 | 67 | 1,524 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/broker/unsafequeues/SegmentPointer.java | SegmentPointer | equals | class SegmentPointer implements Comparable<SegmentPointer> {
private final int idPage;
private final long offset;
public SegmentPointer(int idPage, long offset) {
this.idPage = idPage;
this.offset = offset;
}
/**
* Construct using the segment, but changing the offset.
* *... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SegmentPointer that = (SegmentPointer) o;
return idPage == that.idPage && offset == that.offset;
| 507 | 65 | 572 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/interception/messages/InterceptAcknowledgedMessage.java | StoredMessage | toString | class StoredMessage implements Serializable {
private static final long serialVersionUID = 1755296138639817304L;
private MqttQoS m_qos;
final byte[] m_payload;
final String m_topic;
private boolean m_retained;
private String m_clientID;
public StoredMessage(byte... |
return "PublishEvent{clientID='" + m_clientID + '\'' + ", m_retain="
+ m_retained + ", m_qos=" + m_qos + ", m_topic='" + m_topic + '\'' + '}';
| 386 | 69 | 455 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/logging/LoggingUtils.java | LoggingUtils | getInterceptorIds | class LoggingUtils {
public static <T extends InterceptHandler> Collection<String> getInterceptorIds(Collection<T> handlers) {<FILL_FUNCTION_BODY>}
private LoggingUtils() {
}
} |
Collection<String> result = new ArrayList<>(handlers.size());
for (T handler : handlers) {
result.add(handler.getID());
}
return result;
| 62 | 50 | 112 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/ByteBufDataType.java | ByteBufDataType | read | class ByteBufDataType extends BasicDataType<ByteBuf> {
@Override
public int compare(ByteBuf a, ByteBuf b) {
throw DataUtils.newUnsupportedOperationException("Can not compare");
}
@Override
public int getMemory(ByteBuf obj) {
if (!(obj instanceof ByteBuf)) {
throw new Il... |
final int payloadSize = buff.getInt();
byte[] payload = new byte[payloadSize];
buff.get(payload);
return Unpooled.wrappedBuffer(payload);
| 281 | 51 | 332 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/EnqueuedMessageValueType.java | EnqueuedMessageValueType | write | class EnqueuedMessageValueType extends BasicDataType<EnqueuedMessage> {
private enum MessageType {PUB_REL_MARKER, PUBLISHED_MESSAGE}
private final StringDataType topicDataType = new StringDataType();
private final ByteBufDataType payloadDataType = new ByteBufDataType();
private final PropertiesDataTyp... |
if (obj instanceof SessionRegistry.PublishedMessage) {
buff.put((byte) MessageType.PUBLISHED_MESSAGE.ordinal());
final SessionRegistry.PublishedMessage casted = (SessionRegistry.PublishedMessage) obj;
buff.put((byte) casted.getPublishingQos().value());
final St... | 716 | 261 | 977 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/H2Builder.java | H2Builder | initStore | class H2Builder {
private static final Logger LOG = LoggerFactory.getLogger(H2Builder.class);
private final String storePath;
private final int autosaveInterval; // in seconds
private final ScheduledExecutorService scheduler;
private final Clock clock;
private MVStore mvStore;
public H2Bu... |
LOG.info("Initializing H2 store to {}", storePath);
if (storePath == null || storePath.isEmpty()) {
throw new IllegalArgumentException("H2 store path can't be null or empty");
}
if (!Files.exists(Paths.get(storePath))) {
try {
Files.createFile(Pa... | 346 | 238 | 584 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/H2PersistentQueue.java | H2PersistentQueue | dequeue | class H2PersistentQueue extends AbstractSessionMessageQueue<SessionRegistry.EnqueuedMessage> {
private final MVMap<Long, SessionRegistry.EnqueuedMessage> queueMap;
private final MVMap<String, Long> metadataMap;
private final AtomicLong head;
private final AtomicLong tail;
private final MVStore stor... |
checkDequeuePreconditions();
if (head.equals(tail)) {
return null;
}
final long nextTail = tail.getAndIncrement();
final SessionRegistry.EnqueuedMessage tail = this.queueMap.get(nextTail);
queueMap.remove(nextTail);
this.metadataMap.put("tail", nextTa... | 697 | 104 | 801 | <methods>public non-sealed void <init>() <variables>protected boolean closed |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/H2QueueRepository.java | H2QueueRepository | listQueueNames | class H2QueueRepository implements IQueueRepository {
private MVStore mvStore;
public H2QueueRepository(MVStore mvStore) {
this.mvStore = mvStore;
}
@Override
public Set<String> listQueueNames() {<FILL_FUNCTION_BODY>}
@Override
public boolean containsQueue(String queueName) {
... |
return mvStore.getMapNames().stream()
.filter(name -> name.startsWith("queue_") && !name.endsWith("_meta"))
.map(name -> name.substring("queue_".length()))
.collect(Collectors.toSet());
| 187 | 72 | 259 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/H2RetainedRepository.java | RetainedMessageValueType | read | class RetainedMessageValueType extends BasicDataType<RetainedMessage> {
// Layout for RetainedMessage:
// - topic String
// - qos int
// - payload byte[]
// - flag map to say if contains properties, expiry time (MSB, LSB)
// - (opt) expiry time in epoch millis long
... |
final String topicStr = StringDataType.INSTANCE.read(buff);
final MqttQoS qos = MqttQoS.valueOf(buff.get());
final int payloadSize = buff.getInt();
byte[] payload = new byte[payloadSize];
buff.get(payload);
final byte flags = buff.get();
... | 683 | 328 | 1,011 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/H2SessionsRepository.java | WillDataValueType | getMemory | class WillDataValueType extends BasicDataType<Will> {
private final StringDataType stringDataType = new StringDataType();
private final WillOptionsDataValueType willOptionsDataType = new WillOptionsDataValueType();
@Override
public int getMemory(Will will) {<FILL_FUNCTION_BODY>}
... |
return stringDataType.getMemory(will.topic) +
4 + /* payload length */
will.payload.length +
1 /* retained + qos */;
| 614 | 45 | 659 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/H2SubscriptionsRepository.java | SubscriptionOptionAndIdValueType | read | class SubscriptionOptionAndIdValueType extends BasicDataType<SubscriptionOptionAndId> {
@Override
public int getMemory(SubscriptionOptionAndId obj) {
return 4 + // integer, subscription identifier
SubscriptionOptionValueType.INSTANCE.getMemory(obj.option);
}
... |
int subId = buff.getInt();
MqttSubscriptionOption option = SubscriptionOptionValueType.INSTANCE.read(buff);
if (subId != -1) {
return new SubscriptionOptionAndId(option, subId);
} else {
return new SubscriptionOptionAndId(option);
... | 236 | 84 | 320 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/MemorySubscriptionsRepository.java | MemorySubscriptionsRepository | removeSharedSubscription | class MemorySubscriptionsRepository implements ISubscriptionsRepository {
private static final Logger LOG = LoggerFactory.getLogger(MemorySubscriptionsRepository.class);
private final Set<Subscription> subscriptions = new ConcurrentSkipListSet<>();
private final Map<String, Map<Utils.Couple<ShareName, Topi... |
Map<Utils.Couple<ShareName, Topic>, SharedSubscription> subsMap = sharedSubscriptions.get(clientId);
if (subsMap == null) {
LOG.info("Removing a non existing shared subscription for client: {}", clientId);
return;
}
subsMap.remove(Utils.Couple.of(share, topicFilt... | 739 | 130 | 869 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/PropertiesDataType.java | PropertiesDataType | write | class PropertiesDataType extends BasicDataType<MqttProperties.MqttProperty[]> {
private final PropertyDataType propertyDataType = new PropertyDataType();
@Override
public int getMemory(MqttProperties.MqttProperty[] obj) {
return 4 + // integer containing the number of properties
Arrays... |
// store property list size
buff.putInt(obj.length);
for (MqttProperties.MqttProperty property : obj) {
propertyDataType.write(buff, property);
}
| 241 | 54 | 295 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/PropertyDataType.java | PropertyDataType | read | class PropertyDataType extends BasicDataType<MqttProperties.MqttProperty> {
enum MqttPropertyEnum {STRING, INTEGER, BINARY}
private final ByteBufDataType binaryDataType = new ByteBufDataType();
@Override
public int getMemory(MqttProperties.MqttProperty property) {
int propSize = 4; // property... |
return SerdesUtils.readSingleProperty(buff, buffer -> {
ByteBuf byteArray = binaryDataType.read(buffer);
return byteArray.array();
});
| 691 | 46 | 737 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/SegmentPersistentQueue.java | SegmentPersistentQueue | dequeue | class SegmentPersistentQueue extends AbstractSessionMessageQueue<SessionRegistry.EnqueuedMessage> {
private static final Logger LOG = LoggerFactory.getLogger(SegmentPersistentQueue.class);
private final Queue segmentedQueue;
private final SegmentedPersistentQueueSerDes serdes = new SegmentedPersistentQueu... |
checkDequeuePreconditions();
final Optional<ByteBuffer> dequeue;
try {
dequeue = segmentedQueue.dequeue();
} catch (QueueException e) {
throw new RuntimeException(e);
}
if (!dequeue.isPresent()) {
LOG.debug("No data pulled out from th... | 299 | 146 | 445 | <methods>public non-sealed void <init>() <variables>protected boolean closed |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/SegmentQueueRepository.java | SegmentQueueRepository | close | class SegmentQueueRepository implements IQueueRepository {
private static final Logger LOG = LoggerFactory.getLogger(SegmentQueueRepository.class);
private final QueuePool queuePool;
public SegmentQueueRepository(String path, int pageSize, int segmentSize) throws QueueException {
queuePool = Queu... |
try {
queuePool.close();
} catch (QueueException e) {
LOG.error("Error saving state of the queue pool", e);
}
| 334 | 43 | 377 | <no_super_class> |
moquette-io_moquette | moquette/broker/src/main/java/io/moquette/persistence/SerdesUtils.java | SerdesUtils | readSingleProperty | class SerdesUtils {
static boolean containsProperties(ByteBuffer buff) {
return buff.get() == 1;
}
/**
* Deserialize the array of MqttProperties.
*
* @param propertyDecoder function that read bytes from buffer and create a single MQTT property instance.
* */
public static Mq... |
byte propTypeValue = buff.get();
if (propTypeValue >= PropertyDataType.MqttPropertyEnum.values().length) {
throw new IllegalStateException("Unrecognized property type value: " + propTypeValue);
}
PropertyDataType.MqttPropertyEnum type = PropertyDataType.MqttPropertyEnum.valu... | 292 | 235 | 527 | <no_super_class> |
weibocom_motan | motan/motan-benchmark/motan-benchmark-client/src/main/java/com/weibo/motan/benchmark/AbstractBenchmarkClient.java | AbstractBenchmarkClient | start | class AbstractBenchmarkClient {
private static final int WARMUPTIME = 30;
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private int concurrents;
private int runTime;
private String classname;
private String params;
private ClientStatistics statistics;
... |
this.concurrents = concurrents;
this.runTime = runtime;
this.classname = classname;
this.params = params;
printStartInfo();
// prepare runnables
long currentTime = System.nanoTime() / 1000L;
long startTime = currentTime + WARMUPTIME * 1000 * 1000L;
... | 495 | 433 | 928 | <no_super_class> |
weibocom_motan | motan/motan-benchmark/motan-benchmark-client/src/main/java/com/weibo/motan/benchmark/AbstractClientRunnable.java | AbstractClientRunnable | callService | class AbstractClientRunnable implements ClientRunnable {
RunnableStatistics statistics;
private CyclicBarrier cyclicBarrier;
private CountDownLatch countDownLatch;
private long startTime;
private long endTime;
private int statisticTime;
private BenchmarkService benchmarkService;
public... |
long beginTime = System.nanoTime() / 1000L;
while (beginTime <= startTime) {
// warm up
beginTime = System.nanoTime() / 1000L;
Object result = call(benchmarkService);
}
while (beginTime <= endTime) {
beginTime = System.nanoTime() / 1000L;
... | 625 | 272 | 897 | <no_super_class> |
weibocom_motan | motan/motan-benchmark/motan-benchmark-client/src/main/java/com/weibo/motan/benchmark/ClientStatistics.java | ClientStatistics | printStatistics | class ClientStatistics {
public int statisticTime;
public long above0sum; // [0,1]
public long above1sum; // (1,5]
public long above5sum; // (5,10]
public long above10sum; // (10,50]
public long above50sum; // (50,100]
public long above100sum; // (100,500]
publi... |
System.out.println("Benchmark Run Time: " + statisticTime);
System.out.println(MessageFormat.format("Requests: {0}, Success: {1}%({2}), Error: {3}%({4})", allTPS, succTPS * 100 / allTPS, succTPS, errTPS * 100 / allTPS, errTPS));
System.out.println(MessageFormat.format("Avg TPS: {0}, Max TPS: {1... | 703 | 622 | 1,325 | <no_super_class> |
weibocom_motan | motan/motan-benchmark/motan-benchmark-client/src/main/java/com/weibo/motan/benchmark/MotanBenchmarkClient.java | MotanBenchmarkClient | main | class MotanBenchmarkClient extends AbstractBenchmarkClient {
static Properties properties = new Properties();
/**
* 并发的Runable线程,是否使用相同的client进行调用。
* true:并发线程只使用一个client(bean实例)调用服务。
* false: 每个并发线程使用不同的Client调用服务
*/
private static BenchmarkService benchmarkService;
private static ... |
loadProperties();
int concurrents = Integer.parseInt(properties.getProperty("concurrents"));
int runtime = Integer.parseInt(properties.getProperty("runtime"));
String classname = properties.getProperty("classname");
String params = properties.getProperty("params");
isMul... | 526 | 251 | 777 | <methods>public non-sealed void <init>() ,public abstract com.weibo.motan.benchmark.ClientRunnable getClientRunnable(java.lang.String, java.lang.String, java.util.concurrent.CyclicBarrier, java.util.concurrent.CountDownLatch, long, long) ,public void start(int, int, java.lang.String, java.lang.String) <variables>privat... |
weibocom_motan | motan/motan-benchmark/motan-benchmark-server/src/main/java/com/weibo/motan/benchmark/MotanBenchmarkServer.java | MotanBenchmarkServer | main | class MotanBenchmarkServer {
public static void main(String[] args) throws InterruptedException {<FILL_FUNCTION_BODY>}
} |
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
new String[]{"classpath*:motan-benchmark-server.xml"});
System.out.println("server running---");
Thread.sleep(Long.MAX_VALUE);
| 41 | 63 | 104 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/AbstractAdminCommandHandler.java | AbstractAdminCommandHandler | handle | class AbstractAdminCommandHandler implements AdminCommandHandler {
@Override
public Response handle(Request request) {<FILL_FUNCTION_BODY>}
/**
* Process admin command.
* If the processing fails, an exception can be thrown safely and the upper layer will handle it uniformly.
*
* @param... |
JSONObject result = new JSONObject();
result.put("result", "ok"); // default result.
process(request.getMethodName(), AdminUtil.getParams(request), request.getAttachments(), result);
return AdminUtil.buildResponse(request, result.toJSONString());
| 171 | 74 | 245 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/AbstractAdminServer.java | RpcServerHandler | processLazyDeserialize | class RpcServerHandler implements MessageHandler {
private final Class<?>[] paramClass = new Class[]{Map.class};
private final AdminHandler adminHandler;
public RpcServerHandler(AdminHandler adminHandler) {
this.adminHandler = adminHandler;
}
@Override
publi... |
if (request.getArguments() != null && request.getArguments().length == 1
&& request.getArguments()[0] instanceof DeserializableObject
&& request instanceof DefaultRequest) {
try {
Object[] args = ((DeserializableObject) request.get... | 289 | 137 | 426 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/AdminInitialization.java | AdminInitialization | parsePort | class AdminInitialization implements Initializable {
// default values
private static final String DEFAULT_ADMIN_SERVER = "netty4";
private static final String SECOND_DEFAULT_ADMIN_SERVER = "netty3";
private static final String DEFAULT_ADMIN_PROTOCOL = "http";
@Override
public void init() {
... |
int port = -1;
if (StringUtils.isNotBlank(portStr)) {
try {
port = Integer.parseInt(portStr);
} catch (NumberFormatException e) {
LoggerUtil.warn("AdminInitialization parse admin port from env fail. value:" + portStr);
}
}
... | 1,067 | 89 | 1,156 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/AdminUtil.java | AdminUtil | buildResponse | class AdminUtil {
private static final DefaultPermissionChecker DEFAULT_PERMISSION_CHECKER = new DefaultPermissionChecker();
private static final AdminHandler DEFAULT_ADMIN_HANDLER = new DefaultAdminHandler();
public static AdminHandler getDefaultAdminHandler() {
return DEFAULT_ADMIN_HANDLER;
}... |
DefaultResponse response = new DefaultResponse();
response.setRequestId(request.getRequestId());
response.setRpcProtocolVersion(request.getRpcProtocolVersion());
response.setValue(returnValue);
return response;
| 693 | 60 | 753 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/DefaultAdminHandler.java | DefaultAdminHandler | addCommandHandler | class DefaultAdminHandler implements AdminHandler {
protected PermissionChecker permissionChecker;
protected ConcurrentHashMap<String, AdminCommandHandler> routeHandlers = new ConcurrentHashMap<>();
public DefaultAdminHandler(){
this(AdminUtil.getDefaultPermissionChecker());
}
public Defau... |
String[] commands = adminCommandHandler.getCommandName();
for (String c : commands) {
if (StringUtils.isNotBlank(c)) {
c = c.trim();
if (override) {
routeHandlers.put(c, adminCommandHandler);
} else {
ro... | 458 | 103 | 561 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/DefaultPermissionChecker.java | DefaultPermissionChecker | check | class DefaultPermissionChecker implements PermissionChecker {
public static final String ADMIN_DISABLE_SWITCHER = "feature.motan.admin.disable";
protected String token;
public DefaultPermissionChecker() {
init();
}
@Override
public boolean check(Request request) {<FILL_FUNCTION_BODY>}... |
// check ip
String ip = request.getAttachments().get(URLParamType.host.getName());
if ("127.0.0.1".equals(ip) || "0:0:0:0:0:0:0:1".equals(ip)) {
return true;
}
if (MotanSwitcherUtil.isOpen(ADMIN_DISABLE_SWITCHER)) { // disable token validation and extended validation... | 324 | 166 | 490 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/handler/CommandListHandler.java | CommandListHandler | process | class CommandListHandler extends AbstractAdminCommandHandler {
@Override
protected void process(String command, Map<String, String> params, Map<String, String> attachments, JSONObject result) {<FILL_FUNCTION_BODY>}
@Override
public String[] getCommandName() {
return new String[]{"/command/list... |
JSONArray jsonArray = new JSONArray();
if (AdminUtil.getDefaultAdminHandler() instanceof DefaultAdminHandler) {
jsonArray.addAll(((DefaultAdminHandler) AdminUtil.getDefaultAdminHandler()).getCommandSet());
}
result.put("commandList", jsonArray);
| 91 | 73 | 164 | <methods>public non-sealed void <init>() ,public com.weibo.api.motan.rpc.Response handle(com.weibo.api.motan.rpc.Request) <variables> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/handler/FaultInjectCommandHandler.java | FaultInjectCommandHandler | process | class FaultInjectCommandHandler extends AbstractAdminCommandHandler {
private static final String[] commands = new String[]{
"/faultInjection/config/update",
"/faultInjection/config/clear",
"/faultInjection/config/get"};
static {
String filters = MotanGlobalConfigUti... |
if (commands[0].equals(command)) {
String configs = params.get("configs");
List<FaultInjectionFilter.FaultInjectionConfig> configList = JSONArray.parseArray(configs, FaultInjectionFilter.FaultInjectionConfig.class);
if (configList == null) {
throw new MotanSe... | 234 | 228 | 462 | <methods>public non-sealed void <init>() ,public com.weibo.api.motan.rpc.Response handle(com.weibo.api.motan.rpc.Request) <variables> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/handler/MetaInfoHandler.java | MetaInfoHandler | process | class MetaInfoHandler extends AbstractAdminCommandHandler {
private static final String[] commands = new String[]{
"/meta/update",
"/meta/delete",
"/meta/get",
"/meta/getAll"
};
@Override
protected void process(String command, Map<String, String> params, ... |
if (commands[0].equals(command)) {
params.forEach(GlobalRuntime::putDynamicMeta);
} else if (commands[1].equals(command)) {
GlobalRuntime.removeDynamicMeta(params.get("key"));
} else if (commands[2].equals(command)) {
result.put(params.get("key"), GlobalRunti... | 129 | 139 | 268 | <methods>public non-sealed void <init>() ,public com.weibo.api.motan.rpc.Response handle(com.weibo.api.motan.rpc.Request) <variables> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/admin/handler/RuntimeInfoHandler.java | RuntimeInfoHandler | process | class RuntimeInfoHandler extends AbstractAdminCommandHandler {
@Override
protected void process(String command, Map<String, String> params, Map<String, String> attachments, JSONObject result) {<FILL_FUNCTION_BODY>}
private void addInfos(Map<String, ? extends RuntimeInfo> infos, String key, JSONObject resu... |
result.put(RuntimeInfoKeys.INSTANCE_TYPE_KEY, "motan-java");
result.put(RuntimeInfoKeys.GLOBAL_CONFIG_KEY, MotanGlobalConfigUtil.getConfigs());
// add registry infos
addInfos(GlobalRuntime.getRuntimeRegistries(), RuntimeInfoKeys.REGISTRIES_KEY, result);
// add cluster infos
... | 184 | 237 | 421 | <methods>public non-sealed void <init>() ,public com.weibo.api.motan.rpc.Response handle(com.weibo.api.motan.rpc.Request) <variables> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/closable/ShutDownHook.java | ShutDownHook | runHook | class ShutDownHook extends Thread {
//Smaller the priority is,earlier the resource is to be closed,default Priority is 20
private static final int DEFAULT_PRIORITY = 20;
//only global resource should be register to ShutDownHook,don't register connections to it.
private static ShutDownHook instance;
... |
if (instance != null) {
if (sync) {
instance.run();
} else {
instance.start();
}
}
| 652 | 43 | 695 | <methods>public void <init>() ,public void <init>(java.lang.Runnable) ,public void <init>(java.lang.String) ,public void <init>(java.lang.ThreadGroup, java.lang.Runnable) ,public void <init>(java.lang.ThreadGroup, java.lang.String) ,public void <init>(java.lang.Runnable, java.lang.String) ,public void <init>(java.lang.... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/cluster/ha/FailfastHaStrategy.java | FailfastHaStrategy | call | class FailfastHaStrategy<T> extends AbstractHaStrategy<T> {
@Override
public Response call(Request request, LoadBalance<T> loadBalance) {<FILL_FUNCTION_BODY>}
} |
Referer<T> refer = loadBalance.select(request);
if (refer == null) {
throw new MotanServiceException(String.format("FailfastHaStrategy No referers for request:%s, load balance:%s", request,
loadBalance));
}
return refer.call(request);
| 57 | 82 | 139 | <methods>public non-sealed void <init>() ,public void setUrl(com.weibo.api.motan.rpc.URL) <variables>protected com.weibo.api.motan.rpc.URL url |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/cluster/ha/FailoverHaStrategy.java | FailoverHaStrategy | getTryCount | class FailoverHaStrategy<T> extends AbstractHaStrategy<T> {
protected ThreadLocal<List<Referer<T>>> referersHolder = ThreadLocal.withInitial(ArrayList::new);
@Override
public Response call(Request request, LoadBalance<T> loadBalance) {
if (loadBalance.canSelectMulti()) {
return callWit... |
int tryCount =
url.getMethodParameter(request.getMethodName(), request.getParamtersDesc(), URLParamType.retries.getName(),
URLParamType.retries.getIntValue());
// If it is a negative number, not retry
if (tryCount < 0) {
tryCount = 0;
... | 816 | 91 | 907 | <methods>public non-sealed void <init>() ,public void setUrl(com.weibo.api.motan.rpc.URL) <variables>protected com.weibo.api.motan.rpc.URL url |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/cluster/loadbalance/AbstractLoadBalance.java | AbstractLoadBalance | selectFromRandomStart | class AbstractLoadBalance<T> implements LoadBalance<T> {
public static final int MAX_REFERER_COUNT = 10;
protected URL clusterUrl;
private List<Referer<T>> referers;
@Override
public void init(URL clusterUrl) {
this.clusterUrl = clusterUrl;
}
@Override
public void onRefresh(Li... |
int index = ThreadLocalRandom.current().nextInt(referers.size());
Referer<T> ref;
for (int i = 0; i < referers.size(); i++) {
ref = referers.get((i + index) % referers.size());
if (ref.isAvailable()) {
return ref;
}
}
return nu... | 926 | 97 | 1,023 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/cluster/loadbalance/ActiveWeightLoadBalance.java | ActiveWeightLoadBalance | doSelect | class ActiveWeightLoadBalance<T> extends AbstractLoadBalance<T> {
@Override
protected Referer<T> doSelect(Request request) {<FILL_FUNCTION_BODY>}
@Override
protected void doSelectToHolder(Request request, List<Referer<T>> refersHolder) {
List<Referer<T>> referers = getReferers();
int ... |
List<Referer<T>> referers = getReferers();
int refererSize = referers.size();
int startIndex = ThreadLocalRandom.current().nextInt(refererSize);
int currentCursor = 0;
int currentAvailableCursor = 0;
Referer<T> referer = null;
while (currentAvailableCursor < M... | 402 | 225 | 627 | <methods>public non-sealed void <init>() ,public void init(com.weibo.api.motan.rpc.URL) ,public void onRefresh(List<Referer<T>>) ,public Referer<T> select(com.weibo.api.motan.rpc.Request) ,public void selectToHolder(com.weibo.api.motan.rpc.Request, List<Referer<T>>) ,public void setWeightString(java.lang.String) <varia... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/cluster/loadbalance/ConsistentHashLoadBalance.java | ConsistentHashLoadBalance | doSelect | class ConsistentHashLoadBalance<T> extends AbstractLoadBalance<T> {
private List<Referer<T>> consistentHashReferers;
@Override
public void onRefresh(List<Referer<T>> referers) {
super.onRefresh(referers);
List<Referer<T>> copyReferers = new ArrayList<Referer<T>>(referers);
List<Re... |
int hash = getHash(request);
Referer<T> ref;
for (int i = 0; i < getReferers().size(); i++) {
ref = consistentHashReferers.get((hash + i) % consistentHashReferers.size());
if (ref.isAvailable()) {
return ref;
}
}
return null;
... | 480 | 96 | 576 | <methods>public non-sealed void <init>() ,public void init(com.weibo.api.motan.rpc.URL) ,public void onRefresh(List<Referer<T>>) ,public Referer<T> select(com.weibo.api.motan.rpc.Request) ,public void selectToHolder(com.weibo.api.motan.rpc.Request, List<Referer<T>>) ,public void setWeightString(java.lang.String) <varia... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/cluster/loadbalance/GroupWeightLoadBalanceWrapper.java | MultiGroupSelector | reBuildInnerSelector | class MultiGroupSelector<T> implements Selector<T> {
private final URL clusterUrl;
private final String loadBalanceName;
private List<Referer<T>> referers;
private String weightString;
private volatile InnerSelector<T> innerSelector;
public MultiGroupSelector(URL cluster... |
Map<String, List<Referer<T>>> groupReferers = getGroupReferers(referers);
// CommandServiceManager ensures that there will be no duplicate groups in the weightString
// and no abnormal weight value.
// If it occurs, just throw an exception
String[] groupsAndW... | 813 | 707 | 1,520 | <methods>public non-sealed void <init>() ,public void init(com.weibo.api.motan.rpc.URL) ,public void onRefresh(List<Referer<T>>) ,public Referer<T> select(com.weibo.api.motan.rpc.Request) ,public void selectToHolder(com.weibo.api.motan.rpc.Request, List<Referer<T>>) ,public void setWeightString(java.lang.String) <varia... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/cluster/loadbalance/LocalFirstLoadBalance.java | LocalFirstLoadBalance | doSelectToHolder | class LocalFirstLoadBalance<T> extends AbstractLoadBalance<T> {
public static final int MAX_REFERER_COUNT = 10;
public static long ipToLong(final String addr) {
final String[] addressBytes = addr.split("\\.");
int length = addressBytes.length;
if (length < 3) {
return 0;
... |
List<Referer<T>> referers = getReferers();
List<Referer<T>> localReferers = searchLocalReferer(referers, NetUtils.getLocalAddress().getHostAddress());
if (!localReferers.isEmpty()) {
Collections.sort(localReferers, new LowActivePriorityComparator<T>());
refersHolder.ad... | 765 | 323 | 1,088 | <methods>public non-sealed void <init>() ,public void init(com.weibo.api.motan.rpc.URL) ,public void onRefresh(List<Referer<T>>) ,public Referer<T> select(com.weibo.api.motan.rpc.Request) ,public void selectToHolder(com.weibo.api.motan.rpc.Request, List<Referer<T>>) ,public void setWeightString(java.lang.String) <varia... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/cluster/loadbalance/RoundRobinLoadBalance.java | RoundRobinLoadBalance | doSelect | class RoundRobinLoadBalance<T> extends AbstractLoadBalance<T> {
private final AtomicInteger idx = new AtomicInteger(0);
@Override
protected Referer<T> doSelect(Request request) {<FILL_FUNCTION_BODY>}
@Override
protected void doSelectToHolder(Request request, List<Referer<T>> refersHolder) {
... |
List<Referer<T>> referers = getReferers();
Referer<T> ref = referers.get(getNextNonNegative() % referers.size());
if (ref.isAvailable()) {
return ref;
}
return selectFromRandomStart(referers);
| 198 | 76 | 274 | <methods>public non-sealed void <init>() ,public void init(com.weibo.api.motan.rpc.URL) ,public void onRefresh(List<Referer<T>>) ,public Referer<T> select(com.weibo.api.motan.rpc.Request) ,public void selectToHolder(com.weibo.api.motan.rpc.Request, List<Referer<T>>) ,public void setWeightString(java.lang.String) <varia... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/cluster/support/ClusterSpi.java | ClusterSpi | removeCommonInfos | class ClusterSpi<T> implements Cluster<T> {
private HaStrategy<T> haStrategy;
private LoadBalance<T> loadBalance;
private List<Referer<T>> referers;
private AtomicBoolean available = new AtomicBoolean(false);
private URL url;
@Override
public void init() {
available.set(true);
... |
Map<String, Object> refererInfos = referer.getRuntimeInfo();
if (!CollectionUtil.isEmpty(refererInfos)) {
for (String key : keys) {
refererInfos.remove(key);
}
}
return refererInfos;
| 1,761 | 73 | 1,834 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/codec/AbstractCodec.java | AbstractCodec | initAllSerialization | class AbstractCodec implements Codec {
protected static ConcurrentHashMap<Integer, String> serializations;
protected void serialize(ObjectOutput output, Object message, Serialization serialize) throws IOException {
if (message == null) {
output.writeObject(null);
return;
... |
if (serializations == null) {
serializations = new ConcurrentHashMap<Integer, String>();
try {
ExtensionLoader<Serialization> loader = ExtensionLoader.getExtensionLoader(Serialization.class);
List<Serialization> exts = loader.getExtensions(null);
... | 506 | 222 | 728 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/config/AbstractConfig.java | AbstractConfig | isPrimitive | class AbstractConfig implements Serializable {
private static final long serialVersionUID = 5736580957909744603L;
protected String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
/**
* 按顺序进行config 参数append and override,按照confi... |
return type.isPrimitive() || type == String.class || type == Character.class || type == Boolean.class || type == Byte.class
|| type == Short.class || type == Integer.class || type == Long.class || type == Float.class || type == Double.class;
| 1,667 | 70 | 1,737 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/config/ConfigUtil.java | ConfigUtil | parseExport | class ConfigUtil {
/**
* export fomart: protocol1:port1,protocol2:port2
*
* @param export
* @return
*/
@SuppressWarnings("unchecked")
public static Map<String, Integer> parseExport(String export) {<FILL_FUNCTION_BODY>}
public static String extractProtocols(String export) {
... |
if (StringUtils.isBlank(export)) {
return Collections.emptyMap();
}
Map<String, Integer> pps = new HashMap<String, Integer>();
String[] protocolAndPorts = MotanConstants.COMMA_SPLIT_PATTERN.split(export);
for (String pp : protocolAndPorts) {
if (StringUti... | 211 | 338 | 549 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/config/DefaultGlobalConfig.java | DefaultGlobalConfig | putConfigs | class DefaultGlobalConfig implements GlobalConfig {
private final ConcurrentHashMap<String, String> configs = new ConcurrentHashMap<>();
public DefaultGlobalConfig() {
Map<String, String> defaultConfigs = MotanGlobalConfigUtil.getDefaultConfigCopy();
if (!defaultConfigs.isEmpty()) {
... |
if (configs != null && !configs.isEmpty()) {
for (Map.Entry<String, String> entry : configs.entrySet()) {
if (override) {
this.configs.put(entry.getKey(), entry.getValue());
} else {
this.configs.putIfAbsent(entry.getKey(), ent... | 301 | 102 | 403 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/config/MeshClientConfig.java | MeshClientConfig | initMeshClient | class MeshClientConfig extends AbstractConfig {
// ---------- configuration items ------------
// mesh proxy port
protected Integer port;
// mesh management port
protected Integer mport;
// mesh host ip
protected String host;
// default application for all services
protected String a... |
if (initialized.get()) {
return;
}
buildMeshClientUrl();
DefaultMeshClient defaultMeshClient = new DefaultMeshClient(url);
try {
defaultMeshClient.init();
} catch (Exception e) {
LoggerUtil.error("mesh client init fail. url:" + url.toF... | 1,378 | 184 | 1,562 | <methods>public non-sealed void <init>() ,public java.lang.String getId() ,public void setId(java.lang.String) ,public java.lang.String toString() <variables>private static final java.lang.String[] SUFFIXS,protected java.lang.String id,private static final long serialVersionUID |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/config/RegistryConfig.java | RegistryConfig | toURLs | class RegistryConfig extends AbstractConfig {
private static final long serialVersionUID = 3236055928361714933L;
// 注册配置名称
private String name;
// 注册协议
private String regProtocol;
// 注册中心地址,支持多个ip+port,格式:ip1:port1,ip2:port2,ip3,如果没有port,则使用默认的port
private String address;
// 注册中心缺省端... |
String address = getAddress();
if (StringUtils.isBlank(address)) {
address = NetUtils.LOCALHOST + ":" + MotanConstants.DEFAULT_INT_VALUE;
}
Map<String, String> map = new HashMap<>();
map.putAll(getAddressParams());
appendConfigParams(map);
map.put(URL... | 1,525 | 391 | 1,916 | <methods>public non-sealed void <init>() ,public java.lang.String getId() ,public void setId(java.lang.String) ,public java.lang.String toString() <variables>private static final java.lang.String[] SUFFIXS,protected java.lang.String id,private static final long serialVersionUID |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/config/handler/SimpleConfigHandler.java | SimpleConfigHandler | buildClusterSupport | class SimpleConfigHandler implements ConfigHandler {
@Override
public <T> ClusterSupport<T> buildClusterSupport(Class<T> interfaceClass, List<URL> registryUrls, URL refUrl) {<FILL_FUNCTION_BODY>}
@Override
public <T> T refer(Class<T> interfaceClass, List<Cluster<T>> clusters, String proxyType) {
... |
ClusterSupport<T> clusterSupport = new ClusterSupport<T>(interfaceClass, MeshProxyUtil.processMeshProxy(registryUrls, refUrl, false), refUrl);
clusterSupport.init();
return clusterSupport;
| 925 | 62 | 987 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/core/DefaultThreadFactory.java | DefaultThreadFactory | newThread | class DefaultThreadFactory implements ThreadFactory {
private static final AtomicInteger poolNumber = new AtomicInteger(1);
private final ThreadGroup threadGroup;
private final AtomicInteger currentThreadNumber = new AtomicInteger(1);
private final String namePrefix;
private int priority = Thread.NO... |
Thread thread = new Thread(threadGroup, r, namePrefix + currentThreadNumber.getAndIncrement(), 0);
thread.setDaemon(isDaemon);
thread.setPriority(priority);
return thread;
| 322 | 59 | 381 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/core/StandardThreadExecutor.java | StandardThreadExecutor | execute | class StandardThreadExecutor extends ThreadPoolExecutor {
public static final int DEFAULT_MIN_THREADS = 20;
public static final int DEFAULT_MAX_THREADS = 200;
public static final int DEFAULT_MAX_IDLE_TIME = 60 * 1000; // 1 minutes
protected AtomicInteger submittedTasksCount; // 正在处理的任务数
private int maxSubmitted... |
int count = submittedTasksCount.incrementAndGet();
// 超过最大的并发任务限制,进行 reject
// 依赖的LinkedTransferQueue没有长度限制,因此这里进行控制
if (count > maxSubmittedTaskCount) {
submittedTasksCount.decrementAndGet();
getRejectedExecutionHandler().rejectedExecution(command, this);
return;
}
try {
super.execute(comma... | 741 | 198 | 939 | <methods>public void <init>(int, int, long, java.util.concurrent.TimeUnit, BlockingQueue<java.lang.Runnable>) ,public void <init>(int, int, long, java.util.concurrent.TimeUnit, BlockingQueue<java.lang.Runnable>, java.util.concurrent.ThreadFactory) ,public void <init>(int, int, long, java.util.concurrent.TimeUnit, Block... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/core/extension/ActivationComparator.java | ActivationComparator | compare | class ActivationComparator<T> implements Comparator<T> {
/**
* sequence 大的排在后面,如果没有设置sequence的排到最后面
*/
@Override
public int compare(T o1, T o2) {<FILL_FUNCTION_BODY>}
} |
Activation p1 = o1.getClass().getAnnotation(Activation.class);
Activation p2 = o2.getClass().getAnnotation(Activation.class);
if (p1 == null) {
return 1;
} else if (p2 == null) {
return -1;
} else {
return p1.sequence() - p2.sequence();
... | 79 | 101 | 180 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/exception/MotanAbstractException.java | MotanAbstractException | getMessage | class MotanAbstractException extends RuntimeException {
private static final long serialVersionUID = -8742311167276890503L;
protected MotanErrorMsg motanErrorMsg = MotanErrorMsgConstant.FRAMEWORK_DEFAULT_ERROR;
protected String errorMsg = null;
public MotanAbstractException() {
super();
}
... |
String message = getOriginMessage();
return "error_message: " + message + ", status: " + motanErrorMsg.getStatus() + ", error_code: " + motanErrorMsg.getErrorCode()
+ ",r=" + RpcContext.getContext().getRequestId();
| 720 | 74 | 794 | <methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/filter/AccessLogFilter.java | AccessLogFilter | logAccess | class AccessLogFilter implements Filter {
public static final String ACCESS_LOG_SWITCHER_NAME = "feature.motan.filter.accessLog";
public static final String PRINT_TRACE_LOG_SWITCHER_NAME = "feature.motan.printTraceLog.enable";
private String side;
private Boolean accessLog;
static {
// ini... |
if (getSide() == null) {
String side = caller instanceof Provider ? MotanConstants.NODE_TYPE_SERVICE : MotanConstants.NODE_TYPE_REFERER;
setSide(side);
}
StringBuilder builder = new StringBuilder(128);
append(builder, side);
// application and module fro... | 1,042 | 583 | 1,625 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/filter/AccessStatisticFilter.java | AccessStatisticFilter | filter | class AccessStatisticFilter implements Filter {
private static final String RPC_SERVICE = "rpc_service";
@Override
public Response filter(final Caller<?> caller, final Request request) {<FILL_FUNCTION_BODY>}
} |
long start = System.currentTimeMillis();
AccessStatus accessStatus = AccessStatus.NORMAL;
final long bizProcessTime;
Response response = null;
try {
response = caller.call(request);
if (response != null && response.getException() != null) {
... | 66 | 670 | 736 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/filter/ActiveLimitFilter.java | ActiveLimitFilter | filter | class ActiveLimitFilter implements Filter {
@Override
public Response filter(Caller<?> caller, Request request) {<FILL_FUNCTION_BODY>}
} |
int maxAcvitivyCount = caller.getUrl().getIntParameter(URLParamType.actives.getName(), URLParamType.actives.getIntValue());
if (maxAcvitivyCount > 0) {
int activeCount = RpcStats.getServiceStat(caller.getUrl()).getActiveCount();
if (activeCount >= maxAcvitivyCount) {
... | 46 | 303 | 349 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/filter/FaultInjectionFilter.java | FaultInjectionFilter | filter | class FaultInjectionFilter implements Filter {
@Override
public Response filter(Caller<?> caller, Request request) {<FILL_FUNCTION_BODY>}
public static class FaultInjectionConfig {
public String id; //rule id.
public String servicePattern;
public String methodPattern;
publi... |
FaultInjectionConfig config = FaultInjectionUtil.getGlobalFaultInjectionConfig(request.getInterfaceName(), request.getMethodName());
if (config == null) {
return caller.call(request);
}
Response response;
long delay;
Exception exception = config.getException... | 1,268 | 225 | 1,493 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/filter/ServiceMockFilter.java | ServiceMockFilter | filter | class ServiceMockFilter implements Filter {
private static String RETURN_PREFIX = "return";
private static ConcurrentHashMap<String, MockInfo> mockServices = new ConcurrentHashMap<String, MockInfo>();
public static boolean isDefault(String value) {
return "true".equalsIgnoreCase(value) || "defaul... |
// Do nothing when mock is empty.
String mockServiceName = caller.getUrl().getParameter(URLParamType.mock.getName());
if (StringUtils.isEmpty(mockServiceName) || "false".equals(mockServiceName)) {
return caller.call(request);
}
MockInfo info = getServiceStat(caller... | 1,224 | 818 | 2,042 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/filter/SwitcherFilter.java | SwitcherFilter | mockDefaultResponse | class SwitcherFilter implements Filter {
@Override
public Response filter(Caller<?> caller, Request request) {
// 检查接口或方法降级开关状态
if (MotanSwitcherUtil.isOpen(request.getInterfaceName())
|| MotanSwitcherUtil.isOpen(MotanFrameworkUtil.getFullMethodString(request))) {
// ... |
DefaultResponse response = new DefaultResponse(null, request.getRequestId());
response.setException(new MotanServiceException("Request false for switcher is on"));
return response;
| 222 | 47 | 269 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/filter/ThreadProtectedFilter.java | ThreadProtectedFilter | reject | class ThreadProtectedFilter implements InitializableFilter {
protected static ConcurrentHashMap<String, AtomicInteger> portTotalMap = new ConcurrentHashMap<String, AtomicInteger>();
protected ConcurrentHashMap<String, AtomicInteger> methodMap = new ConcurrentHashMap<String, AtomicInteger>();
protected Atomi... |
DefaultResponse response = new DefaultResponse();
MotanServiceException exception =
new MotanServiceException("ThreadProtectedFilter reject request: request_counter=" + requestCounter + " total_counter="
+ totalCounter + " max_thread=" + maxThread, MotanErrorMsgC... | 721 | 149 | 870 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/protocol/AbstractProtocol.java | AbstractProtocol | refer | class AbstractProtocol implements Protocol {
protected ConcurrentHashMap<String, Exporter<?>> exporterMap = new ConcurrentHashMap<String, Exporter<?>>();
public Map<String, Exporter<?>> getExporterMap() {
return Collections.unmodifiableMap(exporterMap);
}
@SuppressWarnings("unchecked")
@Ov... |
if (url == null) {
throw new MotanFrameworkException(this.getClass().getSimpleName() + " refer Error: url is null",
MotanErrorMsgConstant.FRAMEWORK_INIT_ERROR);
}
if (clz == null) {
throw new MotanFrameworkException(this.getClass().getSimpleName() + ... | 747 | 217 | 964 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/protocol/injvm/InjvmProtocol.java | InjvmReferer | doCall | class InjvmReferer<T> extends AbstractReferer<T> {
private Exporter<T> exporter;
public InjvmReferer(Class<T> clz, URL url, URL serviceUrl) {
super(clz, url, serviceUrl);
}
@Override
protected Response doCall(Request request) {<FILL_FUNCTION_BODY>}
@Suppres... |
if (exporter == null) {
throw new MotanServiceException("InjvmReferer call Error: provider not exist, url=" + url.getUri(),
MotanErrorMsgConstant.SERVICE_UNFOUND);
}
return exporter.getProvider().call(request);
| 230 | 75 | 305 | <methods>public non-sealed void <init>() ,public void destroy() ,public Exporter<T> export(Provider<T>, com.weibo.api.motan.rpc.URL) ,public Map<java.lang.String,Exporter<?>> getExporterMap() ,public Referer<T> refer(Class<T>, com.weibo.api.motan.rpc.URL) ,public Referer<T> refer(Class<T>, com.weibo.api.motan.rpc.URL, ... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/protocol/mock/AbstractMockRpcProtocol.java | AbstractMockRpcProtocol | createReferer | class AbstractMockRpcProtocol extends AbstractProtocol {
private static ProviderMessageRouter mockProviderMessageRouter;
@Override
protected <T> Exporter<T> createExporter(Provider<T> provider, URL url) {
Exporter<T> exporter = new MockRpcExporter<T>(provider, url);
LoggerUtil.info("create ... |
Referer<T> referer = new MockRpcReferer<T>(clz, url, serviceUrl);
LoggerUtil.info("create MockRpcReferer: url={}", url);
return referer;
| 918 | 58 | 976 | <methods>public non-sealed void <init>() ,public void destroy() ,public Exporter<T> export(Provider<T>, com.weibo.api.motan.rpc.URL) ,public Map<java.lang.String,Exporter<?>> getExporterMap() ,public Referer<T> refer(Class<T>, com.weibo.api.motan.rpc.URL) ,public Referer<T> refer(Class<T>, com.weibo.api.motan.rpc.URL, ... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/protocol/rpc/DefaultRpcExporter.java | DefaultRpcExporter | unexport | class DefaultRpcExporter<T> extends AbstractExporter<T> {
protected final ConcurrentHashMap<String, ProviderMessageRouter> ipPort2RequestRouter;
protected final ConcurrentHashMap<String, Exporter<?>> exporterMap;
protected Server server;
protected EndpointFactory endpointFactory;
public DefaultRpc... |
String protocolKey = MotanFrameworkUtil.getProtocolKey(url);
String ipPort = url.getServerPortStr();
Exporter<T> exporter = (Exporter<T>) exporterMap.remove(protocolKey);
if (exporter != null) {
exporter.destroy();
}
ProviderMessageRouter requestRouter = ip... | 743 | 155 | 898 | <methods>public void <init>(Provider<T>, com.weibo.api.motan.rpc.URL) ,public java.lang.String desc() ,public Provider<T> getProvider() ,public Map<java.lang.String,java.lang.Object> getRuntimeInfo() <variables>protected Provider<T> provider |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/protocol/rpc/DefaultRpcReferer.java | DefaultRpcReferer | decrActiveCount | class DefaultRpcReferer<T> extends AbstractReferer<T> {
protected Client client;
protected EndpointFactory endpointFactory;
public DefaultRpcReferer(Class<T> clz, URL url, URL serviceUrl) {
super(clz, url, serviceUrl);
endpointFactory =
ExtensionLoader.getExtensionLoader(En... |
if (!(response instanceof Future)) {
activeRefererCount.decrementAndGet();
return;
}
Future future = (Future) response;
future.addListener(future1 -> activeRefererCount.decrementAndGet());
| 441 | 67 | 508 | <methods>public void <init>(Class<T>, com.weibo.api.motan.rpc.URL) ,public void <init>(Class<T>, com.weibo.api.motan.rpc.URL, com.weibo.api.motan.rpc.URL) ,public int activeRefererCount() ,public com.weibo.api.motan.rpc.Response call(com.weibo.api.motan.rpc.Request) ,public java.lang.String desc() ,public Class<T> getI... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/protocol/v2motan/CompatibleCodec.java | CompatibleCodec | decode | class CompatibleCodec implements Codec {
private Codec v1 = new DefaultRpcCodec();
private Codec v1Compress = new CompressRpcCodec();
private Codec v2 = new MotanV2Codec();
@Override
public byte[] encode(Channel channel, Object message) throws IOException {
if (message instanceof Response) ... |
if (buffer.length < 2) {
throw new MotanServiceException("not enough bytes for decode. length:" + buffer.length);
}
short type = ByteUtil.bytes2short(buffer, 0);
if (type == DefaultRpcCodec.MAGIC) {
return v1Compress.decode(channel, remoteIp, buffer);
} e... | 255 | 150 | 405 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/protocol/v2motan/GrowableByteBuffer.java | GrowableByteBuffer | getVarint | class GrowableByteBuffer {
public static int encodeZigZag32(int value) {
return (value << 1) ^ (value >> 31);
}
public static long encodeZigZag64(long value) {
return (value << 1) ^ (value >> 63);
}
public static int decodeZigZag32(int n) {
return (n >>> 1) ^ -(n & 1);
... |
long result = 0;
for (int shift = 0; shift < 64; shift += 7) {
final byte b = buf.get();
result |= (long) (b & 0x7F) << shift;
if ((b & 0x80) == 0) {
return result;
}
}
throw new MotanServiceException("Integer overflow");
... | 1,514 | 97 | 1,611 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/protocol/v2motan/MotanV2Header.java | MotanV2Header | toBytes | class MotanV2Header {
public static final short MAGIC = (short) 0xF1F1;
private int version = 1;//rpc协议版本号。motan1对应 0, motan2对应1
private boolean heartbeat = false;//是否心跳消息。
private boolean gzip = false; //是否gzip压缩消息
private boolean oneway = false;//是否单向消息。单向消息不需要response
private boolean proxy = ... |
ByteBuffer buf = ByteBuffer.allocate(13);
buf.putShort(MAGIC);
byte msgType = (byte) 0x00;
if (heartbeat) {
msgType = (byte) (msgType | 0x10);
}
if (gzip) {
msgType = (byte) (msgType | 0x08);
}
if (oneway) {
msgType = (... | 1,483 | 349 | 1,832 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/protocol/v2motan/MotanV2Protocol.java | V2RpcReferer | doCall | class V2RpcReferer<T> extends DefaultRpcReferer<T> {
public V2RpcReferer(Class<T> clz, URL url, URL serviceUrl) {
super(clz, url, serviceUrl);
}
@Override
protected Response doCall(Request request) {<FILL_FUNCTION_BODY>}
} |
try {
// use server end group
request.setAttachment(URLParamType.group.getName(), serviceUrl.getGroup());
request.setAttachment(M2_PROXY_PROTOCOL, this.url.getProtocol()); // add proxy protocol for request agent
return client.request(request);... | 94 | 118 | 212 | <methods>public non-sealed void <init>() ,public void destroy() ,public Exporter<T> export(Provider<T>, com.weibo.api.motan.rpc.URL) ,public Map<java.lang.String,Exporter<?>> getExporterMap() ,public Referer<T> refer(Class<T>, com.weibo.api.motan.rpc.URL) ,public Referer<T> refer(Class<T>, com.weibo.api.motan.rpc.URL, ... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/proxy/MeshClientRefererInvocationHandler.java | MeshClientRefererInvocationHandler | invoke | class MeshClientRefererInvocationHandler<T> extends AbstractRefererHandler<T> implements InvocationHandler, CommonClient {
protected MeshClient meshClient;
protected URL refUrl;
/**
* only for InvocationHandler
*/
public MeshClientRefererInvocationHandler(Class<T> clz, URL refUrl, MeshClient ... |
if (isLocalMethod(method)) {
if ("toString".equals(method.getName())) {
return innerToString();
}
if ("equals".equals(method.getName())) {
return refUrl.equals(args[0]);
}
if ("hashCode".equals(method.getName())) {
... | 820 | 169 | 989 | <methods>public non-sealed void <init>() <variables>protected List<Cluster<T>> clusters,protected Class<T> clz,protected java.lang.String interfaceName,protected com.weibo.api.motan.switcher.SwitcherService switcherService |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/proxy/RefererInvocationHandler.java | RefererInvocationHandler | clustersToString | class RefererInvocationHandler<T> extends AbstractRefererHandler<T> implements InvocationHandler {
public RefererInvocationHandler(Class<T> clz, List<Cluster<T>> clusters) {
this.clz = clz;
this.clusters = clusters;
init();
interfaceName = MotanFrameworkUtil.removeAsyncSuffix(clz.ge... |
StringBuilder sb = new StringBuilder();
for (Cluster<T> cluster : clusters) {
sb.append("{protocol:").append(cluster.getUrl().getProtocol());
List<Referer<T>> referers = cluster.getReferers();
if (referers != null) {
for (Referer<T> refer : referers) ... | 407 | 154 | 561 | <methods>public non-sealed void <init>() <variables>protected List<Cluster<T>> clusters,protected Class<T> clz,protected java.lang.String interfaceName,protected com.weibo.api.motan.switcher.SwitcherService switcherService |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/registry/support/AbstractRegistryFactory.java | AbstractRegistryFactory | getRegistry | class AbstractRegistryFactory implements RegistryFactory {
private static final ConcurrentHashMap<String, Registry> registries = new ConcurrentHashMap<>();
private static final ReentrantLock lock = new ReentrantLock();
protected String getRegistryUri(URL url) {
return url.getUri();
}
@Ov... |
String registryUri = getRegistryUri(url);
try {
lock.lock();
Registry registry = registries.get(registryUri);
if (registry != null) {
return registry;
}
registry = createRegistry(url);
if (registry == null) {
... | 122 | 206 | 328 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/registry/support/DirectRegistry.java | DirectRegistry | parseDirectUrl | class DirectRegistry extends AbstractRegistry {
private ConcurrentHashMap<URL, Object> subscribeUrls = new ConcurrentHashMap();
private List<URL> directUrls = new ArrayList<URL>();
public DirectRegistry(URL url) {
super(url);
String address = url.getParameter("address");
if (addres... |
String[] ipAndPort = directUrl.split(":");
String ip = ipAndPort[0];
Integer port = Integer.parseInt(ipAndPort[1]);
if (port < 0 || port > 65535) {
throw new RuntimeException();
}
registerDirectUrl(ip, port);
| 673 | 82 | 755 | <methods>public void <init>(com.weibo.api.motan.rpc.URL) ,public void available(com.weibo.api.motan.rpc.URL) ,public List<com.weibo.api.motan.rpc.URL> discover(com.weibo.api.motan.rpc.URL) ,public Collection<com.weibo.api.motan.rpc.URL> getRegisteredServiceUrls() ,public Map<java.lang.String,java.lang.Object> getRuntim... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/registry/support/LocalRegistryService.java | LocalRegistryService | doSubscribe | class LocalRegistryService extends AbstractRegistry {
/** Map<interface/nodeType, List<URL>>, List 中的url用identity/id来区分唯一性 */
private ConcurrentMap<String, List<URL>> registeredServices = new ConcurrentHashMap<String, List<URL>>();
private ConcurrentHashMap<String, ConcurrentHashMap<URL, ConcurrentHashSet... |
String subscribeKey = getSubscribeKey(url);
ConcurrentHashMap<URL, ConcurrentHashSet<NotifyListener>> urlListeners = subscribeListeners.get(subscribeKey);
if (urlListeners == null) {
subscribeListeners.putIfAbsent(subscribeKey, new ConcurrentHashMap<URL, ConcurrentHashSet<NotifyLis... | 1,517 | 258 | 1,775 | <methods>public void <init>(com.weibo.api.motan.rpc.URL) ,public void available(com.weibo.api.motan.rpc.URL) ,public List<com.weibo.api.motan.rpc.URL> discover(com.weibo.api.motan.rpc.URL) ,public Collection<com.weibo.api.motan.rpc.URL> getRegisteredServiceUrls() ,public Map<java.lang.String,java.lang.Object> getRuntim... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/registry/support/command/CommandFailbackRegistry.java | CommandFailbackRegistry | doUnsubscribe | class CommandFailbackRegistry extends FailbackRegistry {
private ConcurrentHashMap<URL, CommandServiceManager> commandManagerMap;
public CommandFailbackRegistry(URL url) {
super(url);
commandManagerMap = new ConcurrentHashMap<>();
LoggerUtil.info("CommandFailbackRegistry init. url: " +... |
LoggerUtil.info("CommandFailbackRegistry unsubscribe. url: " + url.toSimpleString());
URL urlCopy = url.createCopy();
CommandServiceManager manager = commandManagerMap.get(urlCopy);
manager.removeNotifyListener(listener);
unsubscribeService(urlCopy, manager);
unsubscrib... | 1,066 | 90 | 1,156 | <methods>public void <init>(com.weibo.api.motan.rpc.URL) ,public List<com.weibo.api.motan.rpc.URL> discover(com.weibo.api.motan.rpc.URL) ,public Map<java.lang.String,java.lang.Object> getRuntimeInfo() ,public void register(com.weibo.api.motan.rpc.URL) ,public void subscribe(com.weibo.api.motan.rpc.URL, com.weibo.api.mo... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/registry/support/command/RpcCommand.java | RpcCommand | sort | class RpcCommand {
private List<ClientCommand> clientCommandList;
public void sort() {<FILL_FUNCTION_BODY>}
public static class ClientCommand {
private Integer index;
private String version;
private String dc;
private Integer commandType; // 0:流控,1:降级,2:开关
private ... |
if (clientCommandList != null){
clientCommandList.sort((o1, o2) -> {
Integer i1 = o1.getIndex();
Integer i2 = o2.getIndex();
if (i1 == null) {
return -1;
}
if (i2 == null) {
retur... | 591 | 111 | 702 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/registry/support/command/RpcCommandUtil.java | RpcCommandUtil | stringToCommand | class RpcCommandUtil {
/**
* 把指令字符串转为指令对象
*
* @param commandString
* @return
*/
public static RpcCommand stringToCommand(String commandString) {<FILL_FUNCTION_BODY>}
/**
* 指令对象转为string
*
* @param command
* @return
*/
public static String commandToStrin... |
try {
RpcCommand rpcCommand = JSONObject.parseObject(commandString, RpcCommand.class);
if (rpcCommand != null) {
rpcCommand.sort();
}
return rpcCommand;
} catch (Exception e) {
LoggerUtil.error("指令配置错误:不是合法的JSON格式!");
... | 1,718 | 100 | 1,818 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/AbstractExporter.java | AbstractExporter | getRuntimeInfo | class AbstractExporter<T> extends AbstractNode implements Exporter<T> {
protected Provider<T> provider;
public AbstractExporter(Provider<T> provider, URL url) {
super(url);
this.provider = provider;
}
public Provider<T> getProvider() {
return provider;
}
@Override
... |
Map<String, Object> infos = new HashMap<>();
infos.put(RuntimeInfoKeys.URL_KEY, url.toFullStr());
infos.put(RuntimeInfoKeys.STATE_KEY, init ? "init" : "unInit");
infos.put(RuntimeInfoKeys.PROVIDER_KEY, provider.getRuntimeInfo());
return infos;
| 208 | 94 | 302 | <methods>public void <init>(com.weibo.api.motan.rpc.URL) ,public com.weibo.api.motan.rpc.URL getUrl() ,public synchronized void init() ,public boolean isAvailable() ,public void setAvailable(boolean) <variables>protected volatile boolean available,protected volatile boolean init,protected com.weibo.api.motan.rpc.URL ur... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/AbstractNode.java | AbstractNode | init | class AbstractNode implements Node {
protected URL url;
protected volatile boolean init = false;
protected volatile boolean available = false;
public AbstractNode(URL url) {
this.url = url;
}
@Override
public synchronized void init() {<FILL_FUNCTION_BODY>}
protected abstract... |
if (init) {
LoggerUtil.warn(this.getClass().getSimpleName() + " node already init: " + desc());
return;
}
boolean result = doInit();
if (!result) {
LoggerUtil.error(this.getClass().getSimpleName() + " node init Error: " + desc());
throw ... | 153 | 182 | 335 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/AbstractProvider.java | AbstractProvider | lookupMethod | class AbstractProvider<T> implements Provider<T> {
protected Class<T> clz;
protected URL url;
protected boolean alive = false;
protected boolean close = false;
protected Map<String, Method> methodMap = new HashMap<>();
public AbstractProvider(URL url, Class<T> clz) {
this.url = url;
... |
Method method;
String fullMethodName = ReflectUtil.getMethodDesc(methodName, methodDesc);
method = methodMap.get(fullMethodName);
if (method == null && StringUtils.isBlank(methodDesc)) {
method = methodMap.get(methodName);
if (method == null) {
me... | 566 | 126 | 692 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/AbstractReferer.java | AbstractReferer | call | class AbstractReferer<T> extends AbstractNode implements Referer<T> {
protected Class<T> clz;
protected AtomicInteger activeRefererCount = new AtomicInteger(0);
protected URL serviceUrl;
public AbstractReferer(Class<T> clz, URL url) {
super(url);
this.clz = clz;
this.serviceUrl... |
if (!isAvailable()) {
throw new MotanFrameworkException(this.getClass().getSimpleName() + " call Error: node is not available, url=" + url.getUri()
+ " " + MotanFrameworkUtil.toString(request));
}
incrActiveCount(request);
Response response = null;
... | 442 | 121 | 563 | <methods>public void <init>(com.weibo.api.motan.rpc.URL) ,public com.weibo.api.motan.rpc.URL getUrl() ,public synchronized void init() ,public boolean isAvailable() ,public void setAvailable(boolean) <variables>protected volatile boolean available,protected volatile boolean init,protected com.weibo.api.motan.rpc.URL ur... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/ApplicationInfo.java | ApplicationInfo | addService | class ApplicationInfo {
public static final String STATISTIC = "statisitic";
public static final ConcurrentMap<String, Application> applications = new ConcurrentHashMap<String, Application>();
public static Application getApplication(URL url) {
String app = url.getApplication();
String mod... |
String app = url.getApplication();
String module = url.getModule();
Application application = applications.get(app + "_" + module);
if (application == null) {
applications.putIfAbsent(app + "_" + module, new Application(app, module));
}
| 182 | 74 | 256 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/DefaultCallbackHolder.java | DefaultCallbackHolder | onFinish | class DefaultCallbackHolder implements Callbackable {
private final List<Pair<Runnable, Executor>> taskList = new ArrayList<>();
private volatile boolean isFinished = false;
public void addFinishCallback(Runnable runnable, Executor executor) {
if (!isFinished) {
synchronized (this) {
... |
if (!isFinished) {
synchronized (this) {
if (!isFinished) {
for (Pair<Runnable, Executor> pair : taskList) {
process(pair.getKey(), pair.getValue());
}
isFinished = true;
}
... | 263 | 81 | 344 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/DefaultProvider.java | DefaultProvider | invoke | class DefaultProvider<T> extends AbstractProvider<T> {
protected T proxyImpl;
protected boolean isAsync = false;
public DefaultProvider(T proxyImpl, URL url, Class<T> clz) {
super(url, clz);
this.proxyImpl = proxyImpl;
Class<?> asyncInterface = null;
try {
asyncI... |
DefaultResponse response = new DefaultResponse();
String methodName = request.getMethodName();
if (isAsync) { // change to async method
methodName += "Async";
}
Method method = lookupMethod(methodName, request.getParamtersDesc());
if (method == null) {
... | 356 | 771 | 1,127 | <methods>public void <init>(com.weibo.api.motan.rpc.URL, Class<T>) ,public com.weibo.api.motan.rpc.Response call(com.weibo.api.motan.rpc.Request) ,public java.lang.String desc() ,public void destroy() ,public Class<T> getInterface() ,public com.weibo.api.motan.rpc.URL getUrl() ,public void init() ,public boolean isAvai... |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/DefaultRequest.java | DefaultRequest | toString | class DefaultRequest implements Request, Traceable, Serializable {
private static final long serialVersionUID = 1168814620391610215L;
private String interfaceName;
private String methodName;
private String paramtersDesc;
private Object[] arguments;
private Map<String, String> attachments;
... |
return interfaceName + "." + methodName + "(" + paramtersDesc + ") requestId=" + requestId;
| 787 | 31 | 818 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/DefaultResponse.java | DefaultResponse | updateCallbackHolderFromResponse | class DefaultResponse implements Response, Traceable, Callbackable, Serializable {
private static final long serialVersionUID = 4281186647291615871L;
private Object value;
private Exception exception;
private long requestId;
private long processTime;
private int timeout;
private Map<String, ... |
if (response instanceof Callbackable) {
Callbackable holder = ((Callbackable) response).getCallbackHolder();
if (holder != null) {
callbackHolder = holder;
}
}
| 1,467 | 54 | 1,521 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/RefererSupports.java | RefererSupports | getServerPorts | class RefererSupports {
private static ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(10);
// 正常情况下请求超过1s已经是能够忍耐的极限值了,delay 1s进行destroy
private static final int DELAY_TIME = 1000;
static{
ShutDownHook.registerShutdownHook(new Closable() {
@Override
... |
if (referers == null || referers.isEmpty()) {
return "[]";
}
StringBuilder builder = new StringBuilder();
builder.append("[");
for (Referer<T> referer : referers) {
builder.append(referer.getUrl().getServerPortStr()).append(",");
}
builde... | 411 | 118 | 529 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/RpcContext.java | RpcContext | getRequestId | class RpcContext {
private static final ThreadLocal<RpcContext> LOCAL_CONTEXT = new ThreadLocal<RpcContext>() {
@Override
protected RpcContext initialValue() {
return new RpcContext();
}
};
private Map<Object, Object> attributes = new HashMap<Object, Object>();
privat... |
if (clientRequestId != null) {
return clientRequestId;
} else {
return request == null ? null : String.valueOf(request.getRequestId());
}
| 787 | 50 | 837 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/RpcStats.java | RpcStats | getMethodStat | class RpcStats {
private static final String SEPERATOR_METHOD_AND_PARAM = "|";
private static ConcurrentHashMap<String, StatInfo> serviceStat = new ConcurrentHashMap<String, RpcStats.StatInfo>();
private static ConcurrentHashMap<String, ConcurrentHashMap<String, StatInfo>> methodStat =
new Con... |
ConcurrentHashMap<String, StatInfo> sstats = methodStat.get(uri);
if (sstats == null) {
sstats = new ConcurrentHashMap<String, StatInfo>();
methodStat.putIfAbsent(uri, sstats);
sstats = methodStat.get(uri);
}
String methodNameAndParams = methodName +... | 1,164 | 186 | 1,350 | <no_super_class> |
weibocom_motan | motan/motan-core/src/main/java/com/weibo/api/motan/rpc/TraceableContext.java | TraceableContext | toString | class TraceableContext {
protected AtomicLong receiveTime = new AtomicLong();
protected AtomicLong sendTime = new AtomicLong();
protected Map<String, String> traceInfoMap = new ConcurrentHashMap<>();
public long getReceiveTime() {
return receiveTime.get();
}
public void setReceiveTime(... |
return "send: " + sendTime + ", receive: " + receiveTime + ", info: " + JSON.toJSONString(traceInfoMap);
| 277 | 37 | 314 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.