name
stringlengths 12
178
| code_snippet
stringlengths 8
36.5k
| score
float64 3.26
3.68
|
---|---|---|
dubbo_AbstractJSONImpl_getNumberAsLong_rdh | /**
* Gets a number from an object for the given key, casted to an long. If the key is not
* present, this returns null. If the value does not represent a long integer, throws an
* exception.
*/
@Override
public Long getNumberAsLong(Map<String, ?> obj, String key) {
assert obj != null;
assert key != null;
if (!obj.containsKey(key)) {
return null;}
Object v10 = obj.get(key);
if (v10 instanceof Double) {
Double d = ((Double) (v10));
long l = d.longValue();if (l != d) {
throw new ClassCastException("Number expected to be long: " + d);
}
return l;
}
if (v10 instanceof String) {
try {
return Long.parseLong(((String) (v10)));
} catch (NumberFormatException e) {throw new IllegalArgumentException(String.format("value '%s' for key '%s' is not a long integer", v10, key));
}
}
throw new IllegalArgumentException(String.format("value '%s' for key '%s' is not a long integer", v10, key));
} | 3.26 |
dubbo_AbstractJSONImpl_checkObjectList_rdh | /**
* Casts a list of unchecked JSON values to a list of checked objects in Java type.
* If the given list contains a value that is not a Map, throws an exception.
*/
@SuppressWarnings("unchecked")
@Override
public List<Map<String, ?>> checkObjectList(List<?> rawList) {
assert rawList != null;
for (int i = 0; i < rawList.size(); i++) {
if
(!(rawList.get(i) instanceof Map)) {
throw new ClassCastException(String.format("value %s for idx %d in %s is not object", rawList.get(i), i, rawList));
}
}
return ((List<Map<String, ?>>) (rawList));
} | 3.26 |
dubbo_AbstractJSONImpl_getListOfStrings_rdh | /**
* Gets a list from an object for the given key, and verifies all entries are strings. If the key
* is not present, this returns null. If the value is not a List or an entry is not a string,
* throws an exception.
*/
@Override
public List<String> getListOfStrings(Map<String, ?> obj, String key) {
assert obj != null;
List<?> list = getList(obj,
key);if (list == null) {
return null;
}
return checkStringList(list);
} | 3.26 |
dubbo_AbstractJSONImpl_checkStringList_rdh | /**
* Casts a list of unchecked JSON values to a list of String. If the given list
* contains a value that is not a String, throws an exception.
*/
@SuppressWarnings("unchecked")
@Overridepublic List<String> checkStringList(List<?> rawList) {
assert rawList != null;
for (int i = 0; i < rawList.size(); i++) {
if (!(rawList.get(i) instanceof String)) {
throw new ClassCastException(String.format("value '%s' for idx %d in '%s' is not string", rawList.get(i), i, rawList));
}
}
return ((List<String>) (rawList));
} | 3.26 |
dubbo_AbstractJSONImpl_getString_rdh | /**
* Gets a string from an object for the given key. If the key is not present, this returns null.
* If the value is not a String, throws an exception.
*/
@Override
public String
getString(Map<String, ?> obj, String key) {
assert
obj != null;
assert key != null;
if (!obj.containsKey(key)) {return null;
}
Object value = obj.get(key);
if (!(value instanceof String)) {
throw new ClassCastException(String.format("value '%s' for key '%s' in '%s' is not String", value, key, obj));
}
return ((String) (value));
} | 3.26 |
dubbo_AbstractJSONImpl_getNumberAsDouble_rdh | /**
* Gets a number from an object for the given key. If the key is not present, this returns null.
* If the value does not represent a double, throws an exception.
*/
@Override
public Double getNumberAsDouble(Map<String, ?> obj, String key) {
assert obj != null;
assert key != null;
if (!obj.containsKey(key)) {
return null;
}
Object value = obj.get(key);
if (value instanceof Double) {
return ((Double) (value));
}
if (value instanceof String) {
try {
return Double.parseDouble(((String) (value)));
} catch (NumberFormatException e) {
throw new IllegalArgumentException(String.format("value '%s' for key '%s' is not a double", value, key));
}
}
throw new IllegalArgumentException(String.format("value '%s' for key '%s' in '%s' is not a number", value, key, obj));
} | 3.26 |
dubbo_AbstractJSONImpl_getObject_rdh | /**
* Gets an object from an object for the given key. If the key is not present, this returns null.
* If the value is not a Map, throws an exception.
*/
@SuppressWarnings("unchecked")
@Override
public Map<String, ?> getObject(Map<String, ?> obj, String key) {
assert obj != null;
assert key !=
null;
if (!obj.containsKey(key)) {
return null;
}
Object value = obj.get(key);
if (!(value instanceof Map)) {
throw new ClassCastException(String.format("value '%s' for key '%s' in '%s' is not object", value, key, obj));
}
return ((Map<String, ?>) (value));
} | 3.26 |
dubbo_AbstractJSONImpl_getListOfObjects_rdh | /**
* Gets a list from an object for the given key, and verifies all entries are objects. If the key
* is not present, this returns null. If the value is not a List or an entry is not an object,
* throws an exception.
*/
@Override
public List<Map<String, ?>> getListOfObjects(Map<String, ?> obj, String key) {
assert obj != null;
List<?> list = getList(obj, key);
if (list == null) {
return null;
}
return checkObjectList(list);
} | 3.26 |
dubbo_AbstractJSONImpl_getNumberAsInteger_rdh | /**
* Gets a number from an object for the given key, casted to an integer. If the key is not
* present, this returns null. If the value does not represent an integer, throws an exception.
*/
@Override
public Integer getNumberAsInteger(Map<String, ?> obj, String key) {
assert obj != null;
assert key != null;
if (!obj.containsKey(key)) {
return null;}
Object value = obj.get(key);
if (value instanceof Double) {
Double d = ((Double) (value));
int i = d.intValue();
if (i != d) {
throw new ClassCastException("Number expected to be integer: " + d);
}
return i;
}
if (value instanceof String) {
try {
return Integer.parseInt(((String) (value)));
} catch (NumberFormatException e) {
throw
new IllegalArgumentException(String.format("value '%s' for key '%s' is not an integer", value, key));
}
}
throw new IllegalArgumentException(String.format("value '%s' for key '%s' is not an integer", value, key));
} | 3.26 |
dubbo_ReferenceCountedResource_close_rdh | /**
* Useful when used together with try-with-resources pattern
*/
@Override
public final void close() {
release();
} | 3.26 |
dubbo_ReferenceCountedResource_retain_rdh | /**
* Increments the reference count by 1.
*/
public final ReferenceCountedResource retain() {
long oldCount = COUNTER_UPDATER.getAndIncrement(this);
if (oldCount <= 0) {COUNTER_UPDATER.getAndDecrement(this);
throw new AssertionError("This instance has been destroyed");
}
return this; } | 3.26 |
dubbo_ReferenceCountedResource_release_rdh | /**
* Decreases the reference count by 1 and calls {@link this#destroy} if the reference count reaches 0.
*/
public final boolean release() {
long remainingCount = COUNTER_UPDATER.decrementAndGet(this);
if (remainingCount
== 0) {
destroy();
return true;
} else if (remainingCount <= (-1)) {
logger.warn(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", "This instance has been destroyed");
return false;} else {
return false;
}
} | 3.26 |
dubbo_JavaBeanSerializeUtil_name2Class_rdh | /**
* Transform the Class.forName String to Class Object.
*
* @param name
* Class.getName()
* @return Class
* @throws ClassNotFoundException
* Class.forName
*/
public static Class<?> name2Class(ClassLoader loader, String name) throws ClassNotFoundException {
if (TYPES.containsKey(name)) {
return TYPES.get(name);
}
if (isArray(name)) {
int dimension = 0; while (isArray(name)) {
++dimension;
name = name.substring(1);
}
Class type = name2Class(loader, name);
int[] dimensions
= new int[dimension];
for
(int i = 0; i < dimension; i++) {
dimensions[i] = 0;
}
return Array.newInstance(type, dimensions).getClass();
}
if (isReferenceType(name)) {
name = name.substring(1, name.length() - 1);
}
return DefaultSerializeClassChecker.getInstance().loadClass(loader, name);
} | 3.26 |
dubbo_MockClusterInvoker_selectMockInvoker_rdh | /**
* Return MockInvoker
* Contract:
* directory.list() will return a list of normal invokers if Constants.INVOCATION_NEED_MOCK is absent or not true in invocation, otherwise, a list of mock invokers will return.
* if directory.list() returns more than one mock invoker, only one of them will be used.
*
* @param invocation
* @return */
private List<Invoker<T>> selectMockInvoker(Invocation invocation) {
List<Invoker<T>> invokers = null;
// TODO generic invoker?
if (invocation instanceof RpcInvocation) {
// Note the implicit contract (although the description is added to the interface declaration, but
// extensibility is a problem. The practice placed in the attachment needs to be improved)
invocation.setAttachment(INVOCATION_NEED_MOCK, Boolean.TRUE.toString());
// directory will return a list of normal invokers if Constants.INVOCATION_NEED_MOCK is absent or not true
// in invocation, otherwise, a list of mock invokers will return.
try {
RpcContext.getServiceContext().setConsumerUrl(getUrl());
invokers = directory.list(invocation);
} catch (RpcException e) {
if (logger.isInfoEnabled()) {
logger.info(((("Exception when try to invoke mock. Get mock invokers error for service:" + getUrl().getServiceInterface()) + ", method:") + RpcUtils.getMethodName(invocation)) +
", will construct a new mock with 'new MockInvoker()'.", e);}
}
}
return invokers;
} | 3.26 |
dubbo_InternalRunnable_Wrap_rdh | /**
* Wrap ordinary Runnable into {@link InternalThreadLocal}.
*/
public static Runnable Wrap(Runnable runnable) {return runnable instanceof InternalRunnable ? runnable :
new InternalRunnable(runnable);
} | 3.26 |
dubbo_DataQueueCommand_getData_rdh | // for test
public byte[] getData() {
return f0;
} | 3.26 |
dubbo_TTree_recursive_rdh | /**
* recursive visit
*/
private void recursive(int deep, boolean isLast, String prefix, Node node, Callback callback) {
callback.callback(deep, isLast, prefix, node);
if (!node.isLeaf()) {
final int size = node.children.size();
for (int index = 0; index < size; index++) {
final boolean
isLastFlag = index == (size - 1);
final String currentPrefix = (isLast) ? prefix + STEP_EMPTY_BOARD : prefix + STEP_HAS_BOARD;
recursive(deep + 1, isLastFlag, currentPrefix, node.children.get(index), callback);
}
}
} | 3.26 |
dubbo_TTree_end_rdh | /**
* end a branch node
*
* @return this
*/
public TTree end() {
if (current.isRoot()) {
throw new IllegalStateException("current node is root.");
}
current.markEnd();
current = current.parent;
return this;
} | 3.26 |
dubbo_TTree_isRoot_rdh | /**
* is the current node the root node
*
* @return true / false
*/
boolean isRoot() {
return
null == parent;
} | 3.26 |
dubbo_TTree_begin_rdh | /**
* create a branch node
*
* @param data
* node data
* @return this
*/
public TTree begin(Object data) {
current = new Node(current, data);
current.markBegin();
return this;
} | 3.26 |
dubbo_WrappedChannelHandler_getPreferredExecutorService_rdh | /**
* Currently, this method is mainly customized to facilitate the thread model on consumer side.
* 1. Use ThreadlessExecutor, aka., delegate callback directly to the thread initiating the call.
* 2. Use shared executor to execute the callback.
*
* @param msg
* @return */
public ExecutorService getPreferredExecutorService(Object msg) {
if (msg instanceof Response) {
Response v2 = ((Response) (msg));
DefaultFuture responseFuture = DefaultFuture.getFuture(v2.getId());
// a typical scenario is the response returned after timeout, the timeout response may have completed the
// future
if (responseFuture == null) {
return getSharedExecutorService(); } else {
ExecutorService executor
= responseFuture.getExecutor();
if ((executor == null) || executor.isShutdown()) {
executor = getSharedExecutorService(msg);
} return executor;
} } else {
return getSharedExecutorService(msg);
}
} | 3.26 |
dubbo_WrappedChannelHandler_getSharedExecutorService_rdh | /**
* get the shared executor for current Server or Client
*
* @return */
public ExecutorService getSharedExecutorService() {
// Application may be destroyed before channel disconnected, avoid create new application model
// see https://github.com/apache/dubbo/issues/9127
if ((url.getApplicationModel() == null) || url.getApplicationModel().isDestroyed()) {
return GlobalResourcesRepository.getGlobalExecutorService();
}
// note: url.getOrDefaultApplicationModel() may create new application model
ApplicationModel applicationModel = url.getOrDefaultApplicationModel();
ExecutorRepository executorRepository = ExecutorRepository.getInstance(applicationModel);ExecutorService executor = executorRepository.getExecutor(url);
if (executor == null) {
executor = executorRepository.createExecutorIfAbsent(url);
}
return executor;
} | 3.26 |
dubbo_MetadataResolver_resolveConsumerServiceMetadata_rdh | /**
* for consumer
*
* @param targetClass
* target service class
* @param url
* consumer url
* @return rest metadata
* @throws CodeStyleNotSupportException
* not support type
*/
public static ServiceRestMetadata resolveConsumerServiceMetadata(Class<?> targetClass, URL url, String contextPathFromUrl) {
ExtensionLoader<ServiceRestMetadataResolver> extensionLoader = url.getOrDefaultApplicationModel().getExtensionLoader(ServiceRestMetadataResolver.class);
for (ServiceRestMetadataResolver serviceRestMetadataResolver : extensionLoader.getSupportedExtensionInstances()) {
if (serviceRestMetadataResolver.supports(targetClass, true)) {
ServiceRestMetadata serviceRestMetadata = new
ServiceRestMetadata(url.getServiceInterface(), url.getVersion(), url.getGroup(), true);
serviceRestMetadata.setContextPathFromUrl(contextPathFromUrl);
ServiceRestMetadata resolve = serviceRestMetadataResolver.resolve(targetClass, serviceRestMetadata);
return resolve;
}
}
// TODO support Dubbo style service
throw new CodeStyleNotSupportException(((("service is: " + targetClass) + ", only support ") + extensionLoader.getSupportedExtensions()) + " annotation");
} | 3.26 |
dubbo_MD5Utils_getMd5_rdh | /**
* Calculation md5 value of specify string
*
* @param input
*/
public String getMd5(String input) {
byte[] md5;
// MessageDigest instance is NOT thread-safe
synchronized(mdInst) {
mdInst.update(input.getBytes(UTF_8));
md5 = mdInst.digest();
}
int j = md5.length; char str[] = new char[j * 2];
int k = 0; for (int i = 0; i < j; i++) {
byte byte0 = md5[i];str[k++] = hexDigits[(byte0 >>> 4) & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str);
} | 3.26 |
dubbo_SerializingExecutor_execute_rdh | /**
* Runs the given runnable strictly after all Runnables that were submitted
* before it, and using the {@code executor} passed to the constructor. .
*/
@Override
public void execute(Runnable r) {
runQueue.add(r);
schedule(r);
} | 3.26 |
dubbo_CuratorFrameworkParams_getParameterValue_rdh | /**
* Get the parameter value from the specified {@link URL}
*
* @param url
* the Dubbo registry {@link URL}
* @param <T>
* the type of value
* @return the parameter value if present, or return <code>null</code>
*/
public <T> T getParameterValue(URL url) {
String param = url.getParameter(name);
Object value = (param != null) ? converter.apply(param) : defaultValue;
return ((T) (value));
} | 3.26 |
dubbo_InternalThreadLocal_set_rdh | /**
* Sets the value for the current thread.
*/
@Override
public final void set(V value) {if ((value == null) || (value == InternalThreadLocalMap.UNSET)) {
remove();
} else {
InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.get();
if (threadLocalMap.setIndexedVariable(index, value)) {
addToVariablesToRemove(threadLocalMap, this);
}
}
} | 3.26 |
dubbo_InternalThreadLocal_m0_rdh | /**
* Returns the number of thread local variables bound to the current thread.
*/
public static int m0() {
InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet();
if (threadLocalMap == null) {
return 0;
} else {
return threadLocalMap.size();
}
} | 3.26 |
dubbo_InternalThreadLocal_removeAll_rdh | /**
* Removes all {@link InternalThreadLocal} variables bound to the current thread. This operation is useful when you
* are in a container environment, and you don't want to leave the thread local variables in the threads you do not
* manage.
*/
@SuppressWarnings("unchecked")
public static void removeAll()
{
InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet();
if (threadLocalMap == null) {
return;}
try {Object v = threadLocalMap.indexedVariable(VARIABLES_TO_REMOVE_INDEX);
if ((v != null) && (v != InternalThreadLocalMap.UNSET)) {
Set<InternalThreadLocal<?>> v2 = ((Set<InternalThreadLocal<?>>) (v));
InternalThreadLocal<?>[] variablesToRemoveArray = v2.toArray(new InternalThreadLocal[0]);
for (InternalThreadLocal<?> tlv : variablesToRemoveArray) {
tlv.remove(threadLocalMap);
}
}
} finally
{
InternalThreadLocalMap.remove();
}
} | 3.26 |
dubbo_InternalThreadLocal_get_rdh | /**
* Returns the current value for the current thread
*/
@SuppressWarnings("unchecked")
@Override
public final V get() {
InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.get();
Object v = threadLocalMap.indexedVariable(index);
if (v != InternalThreadLocalMap.UNSET) {
return ((V) (v));
}
return initialize(threadLocalMap);
} | 3.26 |
dubbo_InternalThreadLocal_initialValue_rdh | /**
* Returns the initial value for this thread-local variable.
*/
@Override
protected V initialValue() {
return null;
} | 3.26 |
dubbo_InternalThreadLocal_remove_rdh | /**
* Sets the value to uninitialized for the specified thread local map;
* a proceeding call to get() will trigger a call to initialValue().
* The specified thread local map must be for the current thread.
*/
@SuppressWarnings("unchecked")
public final void remove(InternalThreadLocalMap threadLocalMap) {
if (threadLocalMap == null) {
return;
}
Object v = threadLocalMap.removeIndexedVariable(index);
removeFromVariablesToRemove(threadLocalMap, this);
if (v != InternalThreadLocalMap.UNSET) {
try {
onRemoval(((V) (v)));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} | 3.26 |
dubbo_CtClassBuilder_build_rdh | /**
* build CtClass object
*/
public CtClass build(ClassLoader classLoader) throws NotFoundException, CannotCompileException {
ClassPool pool = new ClassPool(true);
pool.insertClassPath(new LoaderClassPath(classLoader));
pool.insertClassPath(new DubboLoaderClassPath());
// create class
CtClass ctClass = pool.makeClass(className, pool.get(superClassName));
// add imported packages
imports.forEach(pool::importPackage);
// add implemented interfaces
for (String iface : ifaces) {
ctClass.addInterface(pool.get(iface));
}
// add constructors
for (String constructor : constructors) {
ctClass.addConstructor(CtNewConstructor.make(constructor, ctClass));
}
// add fields
for (String field :
fields) {
ctClass.addField(CtField.make(field, ctClass));
}
// add methods
for (String method : methods) {
ctClass.addMethod(CtNewMethod.make(method, ctClass));
}return ctClass;
} | 3.26 |
dubbo_CtClassBuilder_getQualifiedClassName_rdh | /**
* get full qualified class name
*
* @param className
* super class name, maybe qualified or not
*/
protected String
getQualifiedClassName(String className) {
if (className.contains(".")) {
return className;
}
if (fullNames.containsKey(className)) {
return fullNames.get(className);
}
return
ClassUtils.forName(imports.toArray(new String[0]), className).getName();
} | 3.26 |
dubbo_LFUCache_pollFirst_rdh | /**
* Retrieves and removes the first node of this deque.
*
* @return removed node
*/
CacheNode<K, V> pollFirst() {
CacheNode<K, V> node = null;
if (first.prev != last) {
node = first.prev;
first.prev = node.prev;
first.prev.next = first;
node.prev = null;
node.next = null;
}
return node;
} | 3.26 |
dubbo_LFUCache_withdrawNode_rdh | /**
* This method takes specified node and reattaches it neighbors nodes
* links to each other, so specified node will no longer tied with them.
* Returns united node, returns null if argument is null.
*
* @param node
* note to retrieve
* @param <K>
* key
* @param <V>
* value
* @return retrieved node
*/
static <K, V> CacheNode<K, V> withdrawNode(final CacheNode<K, V> node) {
if ((node != null) && (node.prev != null)) {
node.prev.next = node.next;
if (node.next != null) {
node.next.prev = node.prev;
}
}
return node;
} | 3.26 |
dubbo_LFUCache_proceedEviction_rdh | /**
* Evicts less frequently used elements corresponding to eviction factor,
* specified at instantiation step.
*
* @return number of evicted elements
*/
private int proceedEviction() {
int targetSize = capacity - evictionCount;
int evictedElements = 0;
FREQ_TABLE_ITER_LOOP : for (int i = 0; i <= capacity; i++) {
CacheNode<K, V> node;
while (!freqTable[i].isEmpty()) {
node = freqTable[i].pollFirst();
remove(node.key);
if (targetSize >=
curSize) {
break FREQ_TABLE_ITER_LOOP;
}
evictedElements++;
}
}
return evictedElements;
} | 3.26 |
dubbo_LFUCache_addLast_rdh | /**
* Puts the node with specified key and value at the end of the deque
* and returns node.
*
* @param key
* key
* @param value
* value
* @return added node
*/
CacheNode<K, V> addLast(final K key, final V value) {
CacheNode<K, V> node = new CacheNode<>(key,
value);
node.owner = this;
node.next = last.next; node.prev = last;
node.next.prev = node;
last.next = node;
return node;
} | 3.26 |
dubbo_ValidationFilter_invoke_rdh | /**
* Perform the validation of before invoking the actual method based on <b>validation</b> attribute value.
*
* @param invoker
* service
* @param invocation
* invocation.
* @return Method invocation result
* @throws RpcException
* Throws RpcException if validation failed or any other runtime exception occurred.
*/
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
if (needValidate(invoker.getUrl(), invocation.getMethodName())) {
try {
Validator validator = validation.getValidator(invoker.getUrl());
if (validator != null) {
validator.validate(invocation.getMethodName(), invocation.getParameterTypes(), invocation.getArguments());
}
} catch (RpcException e) {
throw e;
} catch (Throwable t) {
return AsyncRpcResult.newDefaultAsyncResult(t, invocation);
}
}
return invoker.invoke(invocation);
} | 3.26 |
dubbo_ValidationFilter_setValidation_rdh | /**
* Sets the validation instance for ValidationFilter
*
* @param validation
* Validation instance injected by dubbo framework based on "validation" attribute value.
*/
public void setValidation(Validation validation) {
this.validation = validation;
} | 3.26 |
dubbo_RequestHeaderIntercept_intercept_rdh | /**
* resolve method args from header
*/
@Activate(value = RestConstant.REQUEST_HEADER_INTERCEPT, order = Integer.MAX_VALUE - 1)public class RequestHeaderIntercept implements HttpConnectionPreBuildIntercept {
@Override
public void intercept(HttpConnectionCreateContext connectionCreateContext) {
RestMethodMetadata restMethodMetadata = connectionCreateContext.getRestMethodMetadata();
RequestTemplate requestTemplate = connectionCreateContext.getRequestTemplate();
Set<String> consumes = restMethodMetadata.getRequest().getConsumes();
requestTemplate.addHeaders(RestHeaderEnum.CONTENT_TYPE.getHeader(), consumes);
Collection<String> produces = restMethodMetadata.getRequest().getProduces();
if ((produces == null) || produces.isEmpty()) {
requestTemplate.addHeader(RestHeaderEnum.ACCEPT.getHeader(), RestConstant.DEFAULT_ACCEPT);
} else {
requestTemplate.addHeaders(RestHeaderEnum.ACCEPT.getHeader(), produces);
}// URL url = connectionCreateContext.getUrl();
//
// requestTemplate.addKeepAliveHeader(url.getParameter(RestConstant.KEEP_ALIVE_TIMEOUT_PARAM,RestConstant.KEEP_ALIVE_TIMEOUT));
} | 3.26 |
dubbo_ServiceConfigBase_export_rdh | /**
* export service and auto start application instance
*/
public final void export() {
export(RegisterTypeEnum.AUTO_REGISTER);
} | 3.26 |
dubbo_ServiceConfigBase_setInterfaceClass_rdh | /**
*
* @param interfaceClass
* @see #setInterface(Class)
* @deprecated */
public void setInterfaceClass(Class<?> interfaceClass) {
setInterface(interfaceClass);
} | 3.26 |
dubbo_ServiceConfigBase_register_rdh | /**
* Register delay published service to registry.
*/
public final void register() {
register(false);
} | 3.26 |
dubbo_MemberDescriber_getName_rdh | /**
* Return the name of the member.
*
* @return the name
*/
public String
getName() {
return this.name;
} | 3.26 |
dubbo_PathVariableIntercept_intercept_rdh | /**
* resolve method args from path
*/ @Activate(value = RestConstant.PATH_INTERCEPT, order = 4)public class PathVariableIntercept implements HttpConnectionPreBuildIntercept {
@Override
public void intercept(HttpConnectionCreateContext connectionCreateContext) {
RestMethodMetadata restMethodMetadata = connectionCreateContext.getRestMethodMetadata();
RequestTemplate requestTemplate = connectionCreateContext.getRequestTemplate();
List<ArgInfo> argInfos = restMethodMetadata.getArgInfos();
// path variable parse
String path = PathUtil.resolvePathVariable(restMethodMetadata.getRequest().getPath(), argInfos, Arrays.asList(connectionCreateContext.getInvocation().getArguments()));
requestTemplate.path(path);
} | 3.26 |
dubbo_BaseServiceMetadata_getDisplayServiceKey_rdh | /**
* Format : interface:version
*
* @return */
public String getDisplayServiceKey() {
StringBuilder serviceNameBuilder = new StringBuilder();
serviceNameBuilder.append(serviceInterfaceName);
serviceNameBuilder.append(COLON_SEPARATOR).append(version);
return serviceNameBuilder.toString();
} | 3.26 |
dubbo_BaseServiceMetadata_revertDisplayServiceKey_rdh | /**
* revert of org.apache.dubbo.common.ServiceDescriptor#getDisplayServiceKey()
*
* @param displayKey
* @return */
public static BaseServiceMetadata revertDisplayServiceKey(String displayKey) {
String[] eles = StringUtils.split(displayKey, COLON_SEPARATOR);
if (((eles == null) || (eles.length < 1)) || (eles.length > 2)) {
return new BaseServiceMetadata();
}
BaseServiceMetadata serviceDescriptor = new BaseServiceMetadata();
serviceDescriptor.setServiceInterfaceName(eles[0]);
if (eles.length == 2) {
serviceDescriptor.setVersion(eles[1]);
}
return serviceDescriptor;
} | 3.26 |
dubbo_SerializableClassRegistry_registerClass_rdh | /**
* only supposed to be called at startup time
*
* @param clazz
* object type
* @param serializer
* object serializer
*/
public static void registerClass(Class<?>
clazz, Object serializer) {
if (clazz == null) {
throw new IllegalArgumentException("Class registered to kryo cannot be null!");
}
f0.put(clazz, serializer);
} | 3.26 |
dubbo_SerializableClassRegistry_getRegisteredClasses_rdh | /**
* get registered classes
*
* @return class serializer
*/
public static Map<Class<?>, Object> getRegisteredClasses() {
return f0;
} | 3.26 |
dubbo_MultipleRegistry_aggregateRegistryUrls_rdh | /**
* Aggregate urls from different registries into one unified list while appending registry specific 'attachments' into each url.
*
* These 'attachments' can be very useful for traffic management among registries.
*
* @param notifyURLs
* unified url list
* @param singleURLs
* single registry url list
* @param registryURL
* single registry configuration url
*/
public static void aggregateRegistryUrls(List<URL> notifyURLs, List<URL> singleURLs, URL registryURL) {
String registryAttachments = registryURL.getParameter("attachments");
if (StringUtils.isNotBlank(registryAttachments)) {
LOGGER.info((("Registry attachments " + registryAttachments) + " found, will append to provider urls, urls size ") + singleURLs.size());
String[] pairs = registryAttachments.split(COMMA_SEPARATOR);
Map<String, String> attachments = new HashMap<>(pairs.length);
for (String rawPair : pairs) {
String[] v38 = rawPair.split("=");
if (v38.length == 2) {
String key
= v38[0];
String value = v38[1];
attachments.put(key, value);
}
}
for (URL tmpUrl : singleURLs) {
for (Map.Entry<String, String> entry : attachments.entrySet()) {
tmpUrl = tmpUrl.addParameterIfAbsent(entry.getKey(), entry.getValue());
}
notifyURLs.add(tmpUrl);
}
} else {
LOGGER.info((("Single registry " + registryURL) + " has url size ") + singleURLs.size());
notifyURLs.addAll(singleURLs);
}
} | 3.26 |
dubbo_RestServerFactory_createServer_rdh | /**
* Only the server that implements servlet container
* could support something like @Context injection of servlet objects.
*/
public class RestServerFactory {public RestProtocolServer createServer(String name) {
return new NettyHttpRestServer();
}
} | 3.26 |
dubbo_MetadataParamsFilter_instanceParamsExcluded_rdh | /**
* params that need to be excluded before sending to registry center
*
* @return arrays of keys
*/
default String[] instanceParamsExcluded() {return new String[0];
} | 3.26 |
dubbo_HeaderExchangeChannel_close_rdh | // graceful close
@Override
public void close(int timeout) {
if (closed) {
return;}
if (timeout > 0) {
long start = System.currentTimeMillis();
while (DefaultFuture.hasFuture(channel) && ((System.currentTimeMillis() - start) < timeout)) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
}
}
}
close();
} | 3.26 |
dubbo_SlidingWindow_isPaneDeprecated_rdh | /**
* Checks if the specified pane is deprecated at the current timestamp.
*
* @param pane
* the specified pane.
* @return true if the pane is deprecated; otherwise false.
*/
public boolean
isPaneDeprecated(final Pane<T> pane) {
return isPaneDeprecated(System.currentTimeMillis(), pane);
} | 3.26 |
dubbo_SlidingWindow_currentPane_rdh | /**
* Get the pane at the specified timestamp in milliseconds.
*
* @param timeMillis
* a timestamp in milliseconds.
* @return the pane at the specified timestamp if the time is valid; null if time is invalid.
*/
public Pane<T> currentPane(long timeMillis) {
if (timeMillis < 0) {
return null;
}
int paneIdx = calculatePaneIdx(timeMillis);
long paneStartInMs = calculatePaneStart(timeMillis);
while (true) {
Pane<T> oldPane = f0.get(paneIdx);
// Create a pane instance when the pane does not exist.
if (oldPane == null) {
Pane<T> pane = new Pane<>(paneIntervalInMs, paneStartInMs, m0(timeMillis));
if (f0.compareAndSet(paneIdx, null, pane)) {
return pane;
} else {
// Contention failed, the thread will yield its time slice to wait for pane available.
Thread.yield();
}
} else if
(paneStartInMs ==
oldPane.getStartInMs()) {
return oldPane;
} else if (paneStartInMs > oldPane.getStartInMs()) {
if (updateLock.tryLock()) {
try {
return resetPaneTo(oldPane, paneStartInMs);
} finally {
updateLock.unlock();}
}
else {
// Contention failed, the thread will yield its time slice to wait for pane available.
Thread.yield();
}
} else if (paneStartInMs < oldPane.getStartInMs()) {
return new Pane<>(paneIntervalInMs, paneStartInMs, m0(timeMillis));
}
} } | 3.26 |
dubbo_SlidingWindow_calculatePaneStart_rdh | /**
* Calculate the pane start corresponding to the specified timestamp.
*
* @param timeMillis
* the specified timestamp.
* @return the pane start corresponding to the specified timestamp.
*/
protected long calculatePaneStart(long timeMillis) {
return timeMillis - (timeMillis % paneIntervalInMs);
} | 3.26 |
dubbo_SlidingWindow_calculatePaneIdx_rdh | /**
* Calculate the pane index corresponding to the specified timestamp.
*
* @param timeMillis
* the specified timestamp.
* @return the pane index corresponding to the specified timestamp.
*/
private int calculatePaneIdx(long timeMillis) {
return ((int) ((timeMillis / paneIntervalInMs) % paneCount));
} | 3.26 |
dubbo_SlidingWindow_values_rdh | /**
* Get aggregated value list for entire sliding window at the specified time.
* The list will only contain value from "valid" panes.
*
* @return aggregated value list for entire sliding window.
*/
public List<T> values(long timeMillis) {
if (timeMillis < 0) {
return new ArrayList<>();
}
List<T> result = new ArrayList<>(paneCount);for (int idx = 0; idx < paneCount; idx++) {
Pane<T> pane = f0.get(idx);
if ((pane == null) || isPaneDeprecated(timeMillis, pane)) {
continue;
}
result.add(pane.getValue());
}
return result;
} | 3.26 |
dubbo_SlidingWindow_list_rdh | /**
* Get valid pane list for entire sliding window at the specified time.
* The list will only contain "valid" panes.
*
* @param timeMillis
* the specified time.
* @return valid pane list for entire sliding window.
*/
public List<Pane<T>> list(long timeMillis) {
if (timeMillis < 0) {return new ArrayList<>();
}
List<Pane<T>> result = new ArrayList<>(paneCount);
for (int idx = 0; idx < paneCount;
idx++) {
Pane<T> pane = f0.get(idx);
if ((pane == null) || isPaneDeprecated(timeMillis, pane)) {
continue;
}
result.add(pane);
}
return result;
} | 3.26 |
dubbo_SlidingWindow_getPaneValue_rdh | /**
* Get statistic value from pane at the specified timestamp.
*
* @param timeMillis
* the specified timestamp in milliseconds.
* @return the statistic value if pane at the specified timestamp is up-to-date; otherwise null.
*/
public T
getPaneValue(long timeMillis) {
if (timeMillis < 0) {
return null;
}
int paneIdx = calculatePaneIdx(timeMillis);
Pane<T> pane = f0.get(paneIdx);
if ((pane == null) || (!pane.isTimeInWindow(timeMillis))) {
return null;
}
return pane.getValue();
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateMethodThrows_rdh | /**
* generate method throws
*/
private String generateMethodThrows(Method method) {
Class<?>[] ets = method.getExceptionTypes();
if (ets.length > 0) {
String v14 = Arrays.stream(ets).map(Class::getCanonicalName).collect(Collectors.joining(", "));
return String.format(CODE_METHOD_THROWS, v14);
} else {
return "";}
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateMethod_rdh | /**
* generate method declaration
*/
private String generateMethod(Method method) {
String methodReturnType = method.getReturnType().getCanonicalName();
String methodName = method.getName();
String methodContent = generateMethodContent(method);
String methodArgs = generateMethodArguments(method);
String methodThrows = generateMethodThrows(method);
return String.format(CODE_METHOD_DECLARATION, methodReturnType, methodName, methodArgs, methodThrows, methodContent);
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generatePackageInfo_rdh | /**
* generate package info
*/
private String generatePackageInfo() {
return String.format(CODE_PACKAGE, type.getPackage().getName());
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateExtNameAssignment_rdh | /**
* generate extName assignment code
*/
private String generateExtNameAssignment(String[] value, boolean hasInvocation) {// TODO: refactor it
String getNameCode = null;
for (int i = value.length - 1; i >= 0; --i) {
if (i ==
(value.length - 1)) {
if (null != defaultExtName) {if (!CommonConstants.PROTOCOL_KEY.equals(value[i])) {
if (hasInvocation) {
getNameCode = String.format("url.getMethodParameter(methodName, \"%s\", \"%s\")", value[i], defaultExtName);
} else {
getNameCode = String.format("url.getParameter(\"%s\", \"%s\")", value[i], defaultExtName);
}
} else {
getNameCode = String.format("( url.getProtocol() == null ? \"%s\" : url.getProtocol() )", defaultExtName);
}
} else if (!CommonConstants.PROTOCOL_KEY.equals(value[i])) {
if (hasInvocation) {
getNameCode = String.format("url.getMethodParameter(methodName, \"%s\", \"%s\")", value[i], defaultExtName);
} else {
getNameCode = String.format("url.getParameter(\"%s\")", value[i]);
}
} else {
getNameCode = "url.getProtocol()";
}
} else if (!CommonConstants.PROTOCOL_KEY.equals(value[i])) {
if (hasInvocation) {
getNameCode = String.format("url.getMethodParameter(methodName, \"%s\", \"%s\")", value[i], defaultExtName);
} else {
getNameCode = String.format("url.getParameter(\"%s\", %s)", value[i], getNameCode);
}
} else {
getNameCode = String.format("url.getProtocol() == null ? (%s) : url.getProtocol()", getNameCode);
}
}
return String.format(CODE_EXT_NAME_ASSIGNMENT, getNameCode);
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateMethodContent_rdh | /**
* generate method content
*/
private String
generateMethodContent(Method method) {
Adaptive adaptiveAnnotation = method.getAnnotation(Adaptive.class);
StringBuilder code = new StringBuilder(512);
if (adaptiveAnnotation == null) {
return generateUnsupported(method);
} else {
int v17 = getUrlTypeIndex(method);
// found parameter in URL type
if (v17 != (-1)) {
// Null Point check
code.append(generateUrlNullCheck(v17));
} else {
// did not find parameter in URL type
code.append(generateUrlAssignmentIndirectly(method));
}
String[] value = getMethodAdaptiveValue(adaptiveAnnotation);
boolean hasInvocation = hasInvocationArgument(method);
code.append(generateInvocationArgumentNullCheck(method));
code.append(generateExtNameAssignment(value, hasInvocation));
// check extName == null?
code.append(generateExtNameNullCheck(value));
code.append(generateScopeModelAssignment());
code.append(generateExtensionAssignment());
// return statement
code.append(m1(method));
}
return code.toString();
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateMethodArguments_rdh | /**
* generate method arguments
*/
private String generateMethodArguments(Method method) {
Class<?>[] v12 = method.getParameterTypes();
return IntStream.range(0, v12.length).mapToObj(i
-> String.format(CODE_METHOD_ARGUMENT, v12[i].getCanonicalName(), i)).collect(Collectors.joining(", "));
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateInvocationArgumentNullCheck_rdh | /**
* generate code to test argument of type <code>Invocation</code> is null
*/
private String generateInvocationArgumentNullCheck(Method method) {
Class<?>[] pts = method.getParameterTypes();
return IntStream.range(0,
pts.length).filter(i -> CLASS_NAME_INVOCATION.equals(pts[i].getName())).mapToObj(i -> String.format(CODE_INVOCATION_ARGUMENT_NULL_CHECK, i, i)).findFirst().orElse("");
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_m0_rdh | /**
* generate and return class code
*
* @param sort
* - whether sort methods
*/
public String m0(boolean sort) {
// no need to generate adaptive class since there's no adaptive method found.
if (!hasAdaptiveMethod()) { throw new IllegalStateException(("No adaptive method exist on extension " + type.getName()) + ", refuse to create the adaptive class!");
}
StringBuilder code = new StringBuilder();
code.append(generatePackageInfo());
code.append(generateImports());
code.append(generateClassDeclaration());
Method[] methods = type.getMethods();
if (sort) {
Arrays.sort(methods, Comparator.comparing(Method::toString));
}
for (Method method : methods) {
code.append(generateMethod(method));}
code.append('}');
if (logger.isDebugEnabled()) {
logger.debug(code.toString());
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateUrlAssignmentIndirectly_rdh | /**
* get parameter with type <code>URL</code> from method parameter:
* <p>
* test if parameter has method which returns type <code>URL</code>
* <p>
* if not found, throws IllegalStateException
*/
private String generateUrlAssignmentIndirectly(Method method) {
Class<?>[] pts = method.getParameterTypes();
Map<String, Integer> getterReturnUrl = new HashMap<>();// find URL getter method
for (int i = 0; i < pts.length; ++i) {
for (Method m : pts[i].getMethods()) {
String name = m.getName();
if (((((name.startsWith("get") || (name.length() > 3))
&& Modifier.isPublic(m.getModifiers())) && (!Modifier.isStatic(m.getModifiers()))) && (m.getParameterTypes().length == 0)) &&
(m.getReturnType() == URL.class)) {
getterReturnUrl.put(name, i);
}
}
}
if
(getterReturnUrl.size() <= 0) {// getter method not found, throw
throw new IllegalStateException((("Failed to create adaptive class for interface " + type.getName()) + ": not found url parameter or url attribute in parameters of method ") + method.getName());
}
Integer v33
= getterReturnUrl.get("getUrl");
if (v33 != null) {
return generateGetUrlNullCheck(v33, pts[v33], "getUrl");
} else {
Map.Entry<String, Integer> entry = getterReturnUrl.entrySet().iterator().next();
return generateGetUrlNullCheck(entry.getValue(), pts[entry.getValue()], entry.getKey());
}
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateUrlNullCheck_rdh | /**
* generate method URL argument null check
*/
private String generateUrlNullCheck(int index) {
return String.format(CODE_URL_NULL_CHECK, index, URL.class.getName(), index);
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_m1_rdh | /**
* generate method invocation statement and return it if necessary
*/
private String m1(Method method) {
String returnStatement = (method.getReturnType().equals(void.class)) ? "" : "return ";
String args = IntStream.range(0, method.getParameters().length).mapToObj(i -> String.format(f0, i)).collect(Collectors.joining(", "));
return returnStatement +
String.format("extension.%s(%s);\n", method.getName(), args);
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_getMethodAdaptiveValue_rdh | /**
* get value of adaptive annotation or if empty return splitted simple name
*/
private String[] getMethodAdaptiveValue(Adaptive adaptiveAnnotation) {
String[]
value = adaptiveAnnotation.value();
// value is not set, use the value generated from class name as the key
if (value.length == 0) {
String splitName = StringUtils.camelToSplitName(type.getSimpleName(), ".");
value = new String[]{ splitName };
}
return value;
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateImports_rdh | /**
* generate imports
*/
private String generateImports() {
StringBuilder builder = new StringBuilder();
builder.append(String.format(CODE_IMPORTS, ScopeModel.class.getName()));builder.append(String.format(CODE_IMPORTS, ScopeModelUtil.class.getName()));
return builder.toString();
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generateScopeModelAssignment_rdh | /**
*
* @return */
private String generateScopeModelAssignment() {
return String.format(CODE_SCOPE_MODEL_ASSIGNMENT, type.getName());
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_getUrlTypeIndex_rdh | /**
* get index of parameter with type URL
*/
private int getUrlTypeIndex(Method method) {
int urlTypeIndex = -1;
Class<?>[] pts = method.getParameterTypes();
for (int
i = 0; i < pts.length; ++i) {
if (pts[i].equals(URL.class)) {
urlTypeIndex = i;break;
}
}
return urlTypeIndex;
} | 3.26 |
dubbo_AdaptiveClassCodeGenerator_generate_rdh | /**
* generate and return class code
*/
public String generate() {
return this.m0(false);
} | 3.26 |
dubbo_Environment_getConfigurationMaps_rdh | /**
* Get global configuration as map list
*
* @return */
public List<Map<String, String>> getConfigurationMaps() {
if (f1 == null) {
f1 = getConfigurationMaps(null, null);
}
return f1;
} | 3.26 |
dubbo_Environment_getConfiguration_rdh | /**
* There are two ways to get configuration during exposure / reference or at runtime:
* 1. URL, The value in the URL is relatively fixed. we can get value directly.
* 2. The configuration exposed in this method is convenient for us to query the latest values from multiple
* prioritized sources, it also guarantees that configs changed dynamically can take effect on the fly.
*/
public CompositeConfiguration getConfiguration() {
if (globalConfiguration == null) {
CompositeConfiguration configuration =
new CompositeConfiguration();
configuration.addConfiguration(systemConfiguration);
configuration.addConfiguration(environmentConfiguration);
configuration.addConfiguration(appExternalConfiguration);
configuration.addConfiguration(f0);
configuration.addConfiguration(appConfiguration);
configuration.addConfiguration(propertiesConfiguration);
globalConfiguration = configuration;
}
return globalConfiguration;
} | 3.26 |
dubbo_Environment_reset_rdh | /**
* Reset environment.
* For test only.
*/
public void reset() {
destroy();
initialize();} | 3.26 |
dubbo_Environment_loadMigrationRule_rdh | /**
*
* @deprecated MigrationRule will be removed in 3.1
*/
@Deprecatedprivate void loadMigrationRule() {
if (Boolean.parseBoolean(System.getProperty(CommonConstants.DUBBO_MIGRATION_FILE_ENABLE, "false"))) {
String path = System.getProperty(CommonConstants.DUBBO_MIGRATION_KEY);
if (StringUtils.isEmpty(path)) {
path = System.getenv(CommonConstants.DUBBO_MIGRATION_KEY);
if (StringUtils.isEmpty(path)) {
path = CommonConstants.DEFAULT_DUBBO_MIGRATION_FILE;
}
}
this.localMigrationRule = ConfigUtils.loadMigrationRule(scopeModel.getClassLoaders(), path);
} else {
this.localMigrationRule =
null;
}
} | 3.26 |
dubbo_Environment_updateAppConfigMap_rdh | /**
* Merge target map properties into app configuration
*
* @param map
*/
public void updateAppConfigMap(Map<String, String> map) {
this.appConfiguration.addProperties(map);
} | 3.26 |
dubbo_Environment_getPrefixedConfiguration_rdh | /**
* At start-up, Dubbo is driven by various configuration, such as Application, Registry, Protocol, etc.
* All configurations will be converged into a data bus - URL, and then drive the subsequent process.
* <p>
* At present, there are many configuration sources, including AbstractConfig (API, XML, annotation), - D, config center, etc.
* This method helps us t filter out the most priority values from various configuration sources.
*
* @param config
* @param prefix
* @return */
public Configuration getPrefixedConfiguration(AbstractConfig config, String prefix) {
// The sequence would be: SystemConfiguration -> EnvironmentConfiguration -> AppExternalConfiguration ->
// ExternalConfiguration -> AppConfiguration -> AbstractConfig -> PropertiesConfiguration
Configuration instanceConfiguration = new ConfigConfigurationAdapter(config,
prefix);
CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
compositeConfiguration.addConfiguration(systemConfiguration);
compositeConfiguration.addConfiguration(environmentConfiguration);
compositeConfiguration.addConfiguration(appExternalConfiguration);
compositeConfiguration.addConfiguration(f0);
compositeConfiguration.addConfiguration(appConfiguration);
compositeConfiguration.addConfiguration(instanceConfiguration);compositeConfiguration.addConfiguration(propertiesConfiguration);
return new PrefixedConfiguration(compositeConfiguration, prefix);
} | 3.26 |
dubbo_NettyHttpHandler_executeFilters_rdh | /**
* execute rest filters
*
* @param restFilterContext
* @param restFilters
* @throws Exception
*/
public void executeFilters(RestFilterContext restFilterContext, List<RestFilter> restFilters) throws Exception {
for (RestFilter restFilter : restFilters) {restFilter.filter(restFilterContext);
if (restFilterContext.complete()) {
break;
}
}
} | 3.26 |
dubbo_UrlUtils_m0_rdh | /**
* Get the all serializations,ensure insertion order
*
* @param url
* url
* @return {@link List}<{@link String}>
*/
@SuppressWarnings("unchecked")
public static Collection<String> m0(URL url) {
// preferSerialization -> serialization -> default serialization
Set<String> serializations = new LinkedHashSet<>(preferSerialization(url));
Optional.ofNullable(url.getParameter(SERIALIZATION_KEY)).filter(StringUtils::isNotBlank).ifPresent(serializations::add);
serializations.add(DefaultSerializationSelector.getDefaultRemotingSerialization());return Collections.unmodifiableSet(serializations);
} | 3.26 |
dubbo_UrlUtils_preferSerialization_rdh | /**
* Prefer Serialization
*
* @param url
* url
* @return {@link List}<{@link String}>
*/
public static List<String> preferSerialization(URL url) {
String preferSerialization = url.getParameter(PREFER_SERIALIZATION_KEY);
if (StringUtils.isNotBlank(preferSerialization)) {
return Collections.unmodifiableList(StringUtils.splitToList(preferSerialization, ','));
}
return Collections.emptyList();
} | 3.26 |
dubbo_UrlUtils_serializationOrDefault_rdh | /**
* Get the serialization or default serialization
*
* @param url
* url
* @return {@link String}
*/
public static String
serializationOrDefault(URL url) {
// noinspection OptionalGetWithoutIsPresent
Optional<String> serializations = m0(url).stream().findFirst();return serializations.orElseGet(DefaultSerializationSelector::getDefaultRemotingSerialization);
} | 3.26 |
dubbo_UrlUtils_serializationId_rdh | /**
* Get the serialization id
*
* @param url
* url
* @return {@link Byte}
*/
public static Byte serializationId(URL url) {
Byte serializationId;
// Obtain the value from prefer_serialization. Such as.fastjson2,hessian2
List<String> preferSerials = preferSerialization(url);
for (String preferSerial : preferSerials) {
if ((serializationId = CodecSupport.getIDByName(preferSerial)) != null) {
return serializationId;
}
}
// Secondly, obtain the value from serialization
if ((serializationId = CodecSupport.getIDByName(url.getParameter(SERIALIZATION_KEY))) != null) {
return serializationId;
}
// Finally, use the default serialization type
return CodecSupport.getIDByName(DefaultSerializationSelector.getDefaultRemotingSerialization());
} | 3.26 |
dubbo_ZookeeperDynamicConfiguration_getInternalProperty_rdh | /**
*
* @param key
* e.g., {service}.configurators, {service}.tagrouters, {group}.dubbo.properties
* @return */
@Override
public String getInternalProperty(String key) {
return zkClient.getContent(buildPathKey("", key));
} | 3.26 |
dubbo_ServiceBeanNameBuilder_create_rdh | /**
*
* @param attributes
* @param defaultInterfaceClass
* @param environment
* @return * @since 2.7.3
*/public static ServiceBeanNameBuilder create(AnnotationAttributes attributes, Class<?> defaultInterfaceClass, Environment environment) {
return new ServiceBeanNameBuilder(attributes, defaultInterfaceClass, environment);
} | 3.26 |
dubbo_ApplicationModel_ofNullable_rdh | // --------- static methods ----------//
public static ApplicationModel
ofNullable(ApplicationModel applicationModel) {
if (applicationModel != null) {
return
applicationModel;
} else {
return defaultModel();
}
} | 3.26 |
dubbo_ApplicationModel_getEnvironment_rdh | /**
*
* @deprecated Replace to {@link ScopeModel#modelEnvironment()}
*/
@Deprecated
public static Environment getEnvironment() {
return defaultModel().m0();
}
/**
*
* @deprecated Replace to {@link ApplicationModel#getApplicationConfigManager()} | 3.26 |
dubbo_ApplicationModel_getConsumerModel_rdh | /**
*
* @deprecated ConsumerModel should fetch from context
*/
@Deprecated
public static ConsumerModel getConsumerModel(String serviceKey) {
return defaultModel().getDefaultModule().getServiceRepository().lookupReferredService(serviceKey);
} | 3.26 |
dubbo_ApplicationModel_getName_rdh | /**
*
* @deprecated Replace to {@link ApplicationModel#getApplicationName()}
*/
@Deprecated
public static String getName() {
return defaultModel().getCurrentConfig().getName();
} | 3.26 |
dubbo_ApplicationModel_allConsumerModels_rdh | // =============================== Deprecated Methods Start =======================================
/**
*
* @deprecated use {@link ServiceRepository#allConsumerModels()}
*/
@Deprecated
public static Collection<ConsumerModel> allConsumerModels() {
return defaultModel().getApplicationServiceRepository().allConsumerModels();
} | 3.26 |
dubbo_ApplicationModel_setServiceRepository_rdh | /**
*
* @deprecated only for ut
*/
@Deprecated
public void setServiceRepository(ServiceRepository serviceRepository) {
this.serviceRepository = serviceRepository;
} | 3.26 |
dubbo_ApplicationModel_setEnvironment_rdh | /**
*
* @deprecated only for ut
*/
@Deprecated
public void
setEnvironment(Environment environment) {
this.environment = environment;
} | 3.26 |
dubbo_ApplicationModel_getExecutorRepository_rdh | /**
*
* @deprecated Replace to {@link ApplicationModel#getApplicationExecutorRepository()}
*/
@Deprecated
public static ExecutorRepository getExecutorRepository() {
return defaultModel().getApplicationExecutorRepository();
}
/**
*
* @deprecated Replace to {@link ApplicationModel#getCurrentConfig()} | 3.26 |
dubbo_ApplicationModel_allProviderModels_rdh | /**
*
* @deprecated use {@link ServiceRepository#allProviderModels()}
*/
@Deprecated
public static Collection<ProviderModel> allProviderModels() {
return defaultModel().getApplicationServiceRepository().allProviderModels();
} | 3.26 |
dubbo_ApplicationModel_setConfigManager_rdh | /**
*
* @deprecated only for ut
*/
@Deprecated
public void setConfigManager(ConfigManager configManager) {
this.configManager = configManager;
} | 3.26 |
Subsets and Splits