name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
Activiti_ProcessEngines_m0_rdh
/** * Get initialization results. Only info will we available for process engines which were added in the {@link ProcessEngines#init()}. No {@link ProcessEngineInfo} is available for engines which were * registered programatically. */ public static ProcessEngineInfo m0(String processEngineName) { return f0.get(processEngineName); }
3.26
Activiti_MultiSchemaMultiTenantProcessEngineConfiguration_registerTenant_rdh
/** * Add a new {@link DataSource} for a tenant, identified by the provided tenantId, to the engine. * This can be done after the engine has booted up. * * Note that the tenant identifier must have been added to the {@link TenantInfoHolder} *prior* * to calling this method. */ public void registerTenant(String tenantId, DataSource dataSource) { ((TenantAwareDataSource) (super.getDataSource())).addDataSource(tenantId, dataSource); if (booted) { createTenantSchema(tenantId); createTenantAsyncJobExecutor(tenantId); tenantInfoHolder.setCurrentTenantId(tenantId); super.postProcessEngineInitialisation(); tenantInfoHolder.clearCurrentTenantId(); } }
3.26
Activiti_CommandContext_getCommand_rdh
// getters and setters // ////////////////////////////////////////////////////// public Command<?> getCommand() { return command; }
3.26
Activiti_CommandContext_addInvolvedExecution_rdh
// Involved executions //////////////////////////////////////////////////////// public void addInvolvedExecution(ExecutionEntity executionEntity) { if (executionEntity.getId() != null) { involvedExecutions.put(executionEntity.getId(), executionEntity); } }
3.26
Activiti_CommandContext_m0_rdh
/** * Stores the provided exception on this {@link CommandContext} instance. * That exception will be rethrown at the end of closing the {@link CommandContext} instance. * <p> * If there is already an exception being stored, a 'masked exception' message will be logged. */ public void m0(Throwable exception) { if (this.exception == null) { this.exception = exception; } else { log.error("masked exception in command context. for root cause, see below as it will be rethrown later.", exception); LogMDC.clear(); } }
3.26
Activiti_BpmnParser_createParse_rdh
/** * Creates a new {@link BpmnParse} instance that can be used to parse only one BPMN 2.0 process definition. */ public BpmnParse createParse() { return f0.createBpmnParse(this); }
3.26
Activiti_AbstractOperation_findFirstParentScopeExecution_rdh
/** * Returns the first parent execution of the provided execution that is a scope. */ protected ExecutionEntity findFirstParentScopeExecution(ExecutionEntity executionEntity) { ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); ExecutionEntity parentScopeExecution = null; ExecutionEntity currentlyExaminedExecution = executionEntityManager.findById(executionEntity.getParentId()); while ((currentlyExaminedExecution != null) && (parentScopeExecution == null)) { if (currentlyExaminedExecution.isScope()) { parentScopeExecution = currentlyExaminedExecution; } else { currentlyExaminedExecution = executionEntityManager.findById(currentlyExaminedExecution.getParentId()); } } return parentScopeExecution; }
3.26
Activiti_AbstractOperation_executeExecutionListeners_rdh
/** * Executes the execution listeners defined on the given element, with the given event type. * Uses the {@link #execution} of this operation instance as argument for the execution listener. */ protected void executeExecutionListeners(HasExecutionListeners elementWithExecutionListeners, String eventType) { m0(elementWithExecutionListeners, execution, eventType); }
3.26
Activiti_AbstractOperation_getCurrentFlowElement_rdh
/** * Helper method to match the activityId of an execution with a FlowElement of the process definition referenced by the execution. */ protected FlowElement getCurrentFlowElement(final ExecutionEntity execution) { if (execution.getCurrentFlowElement() != null) { return execution.getCurrentFlowElement(); } else if (execution.getCurrentActivityId() != null) { String processDefinitionId = execution.getProcessDefinitionId(); Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); String activityId = execution.getCurrentActivityId(); FlowElement currentFlowElement = process.getFlowElement(activityId, true); return currentFlowElement; } return null; }
3.26
Activiti_AbstractOperation_m0_rdh
/** * Executes the execution listeners defined on the given element, with the given event type, * and passing the provided execution to the {@link ExecutionListener} instances. */ protected void m0(HasExecutionListeners elementWithExecutionListeners, ExecutionEntity executionEntity, String eventType) { commandContext.getProcessEngineConfiguration().getListenerNotificationHelper().executeExecutionListeners(elementWithExecutionListeners, executionEntity, eventType); }
3.26
dubbo_AppResponse_setAttachments_rdh
/** * Append all items from the map into the attachment, if map is empty then nothing happens * * @param map * contains all key-value pairs to append */ public void setAttachments(Map<String, String> map) { this.attachments = (map == null) ? new HashMap<>() : new HashMap<>(map); }
3.26
dubbo_RpcServiceContext_getLocalHostName_rdh
/** * get local host name. * * @return local host name */ @Override public String getLocalHostName() { String host = (localAddress == null) ? null : localAddress.getHostName(); if (StringUtils.isEmpty(host)) { return getLocalHost();} return host;}
3.26
dubbo_RpcServiceContext_getRemoteAddress_rdh
/** * get remote address. * * @return remote address */@Override public InetSocketAddress getRemoteAddress() { return remoteAddress; }
3.26
dubbo_RpcServiceContext_getRemoteHost_rdh
/** * get remote host. * * @return remote host */ @Override public String getRemoteHost() { return remoteAddress == null ? null : remoteAddress.getAddress() == null ? remoteAddress.getHostName() : NetUtils.filterLocalHost(remoteAddress.getAddress().getHostAddress()); }
3.26
dubbo_RpcServiceContext_getInvokers_rdh
/** * * @deprecated Replace to getUrls() */ @Override @Deprecated @SuppressWarnings({ "unchecked", "rawtypes" }) public List<Invoker<?>> getInvokers() { return (invokers == null) && (invoker != null) ? ((List) (Arrays.asList(invoker))) : invokers; }
3.26
dubbo_RpcServiceContext_getRequest_rdh
/** * Get the request object of the underlying RPC protocol, e.g. HttpServletRequest * * @return null if the underlying protocol doesn't provide support for getting request or the request is not of the specified type */ @Override @SuppressWarnings("unchecked") public <T> T getRequest(Class<T> clazz) { return (request != null) && clazz.isAssignableFrom(request.getClass()) ? ((T) (request)) : null; }
3.26
dubbo_RpcServiceContext_getLocalHost_rdh
/** * get local host. * * @return local host */ @Override public String getLocalHost() { String host = (localAddress == null) ? null : localAddress.getAddress() == null ? localAddress.getHostName() : NetUtils.filterLocalHost(localAddress.getAddress().getHostAddress()); if ((host == null) || (host.length() == 0)) { return NetUtils.getLocalHost(); } return host; }
3.26
dubbo_RpcServiceContext_getMethodName_rdh
/** * get method name. * * @return method name. */ @Override public String getMethodName() { return methodName; }
3.26
dubbo_RpcServiceContext_getResponse_rdh
/** * Get the response object of the underlying RPC protocol, e.g. HttpServletResponse * * @return null if the underlying protocol doesn't provide support for getting response or the response is not of the specified type */ @Override @SuppressWarnings("unchecked") public <T> T getResponse(Class<T> clazz) { return (response != null) && clazz.isAssignableFrom(response.getClass()) ? ((T) (response)) : null; }
3.26
dubbo_RpcServiceContext_getInvoker_rdh
/** * * @deprecated Replace to getUrl() */ @Override @Deprecated public Invoker<?> getInvoker() { return invoker; }
3.26
dubbo_RpcServiceContext_getLocalPort_rdh
/** * get local port. * * @return port */ @Override public int getLocalPort() { return localAddress == null ? 0 : localAddress.getPort(); }
3.26
dubbo_RpcServiceContext_getInvocation_rdh
/** * * @deprecated Replace to getMethodName(), getParameterTypes(), getArguments() */ @Override@Deprecated public Invocation getInvocation() { return invocation; }
3.26
dubbo_RpcServiceContext_isServerSide_rdh
/** * * @deprecated Replace to isProviderSide() */ @Override @Deprecated public boolean isServerSide() { return isProviderSide(); }
3.26
dubbo_RpcServiceContext_getRemoteHostName_rdh
/** * get remote host name. * * @return remote host name */ @Override public String getRemoteHostName() { return remoteAddress == null ? null : remoteAddress.getHostName(); }
3.26
dubbo_RpcServiceContext_getRemoteAddressString_rdh
/** * get remote address string. * * @return remote address string. */ @Override public String getRemoteAddressString() { return (getRemoteHost() + ":") + getRemotePort(); }
3.26
dubbo_RpcServiceContext_setRemoteAddress_rdh
/** * set remote address. * * @param address * @return context */ @Override public RpcServiceContext setRemoteAddress(InetSocketAddress address) { this.remoteAddress = address; return this; }
3.26
dubbo_RpcServiceContext_getParameterTypes_rdh
/** * get parameter types. * * @serial */ @Override public Class<?>[] getParameterTypes() {return parameterTypes; }
3.26
dubbo_RpcServiceContext_asyncCall_rdh
/** * one way async call, send request only, and result is not required * * @param runnable */ @Override public void asyncCall(Runnable runnable) { try { setAttachment(RETURN_KEY, Boolean.FALSE.toString()); runnable.run(); } catch (Throwable e) { // FIXME should put exception in future? throw new RpcException("oneway call error ." + e.getMessage(), e); } finally { removeAttachment(RETURN_KEY); } }
3.26
dubbo_RpcServiceContext_isClientSide_rdh
/** * * @deprecated Replace to isConsumerSide() */ @Override @Deprecated public boolean isClientSide() { return isConsumerSide(); }
3.26
dubbo_RpcServiceContext_setLocalAddress_rdh
/** * set local address. * * @param address * @return context */ @Override public RpcServiceContext setLocalAddress(InetSocketAddress address) { this.localAddress = address; return this; }
3.26
dubbo_RpcServiceContext_isProviderSide_rdh
/** * is provider side. * * @return provider side. */ @Override public boolean isProviderSide() { return !isConsumerSide(); }
3.26
dubbo_RpcServiceContext_isConsumerSide_rdh
/** * is consumer side. * * @return consumer side. */ @Override public boolean isConsumerSide() { return getUrl().getSide(PROVIDER_SIDE).equals(CONSUMER_SIDE); }
3.26
dubbo_RpcServiceContext_copyOf_rdh
/** * Only part of the properties are copied, the others are either not used currently or can be got from invocation. * Also see {@link RpcContextAttachment#copyOf(boolean)} * * @param needCopy * @return a shallow copy of RpcServiceContext */ public RpcServiceContext copyOf(boolean needCopy) { if (needCopy) { RpcServiceContext copy = new RpcServiceContext(); copy.arguments = this.arguments; copy.consumerUrl = this.consumerUrl; copy.invocation = this.invocation; copy.invokers = this.invokers; copy.invoker = this.invoker; copy.localAddress = this.localAddress; copy.methodName = this.methodName; copy.needPrintRouterSnapshot = this.needPrintRouterSnapshot; copy.parameterTypes = this.parameterTypes; copy.remoteAddress = this.remoteAddress; copy.remoteApplicationName = this.remoteApplicationName; copy.request = this.request; copy.response = this.response; copy.url = this.url; copy.urls = this.urls; return copy; } else { return this; }}
3.26
dubbo_RegistryManager_reset_rdh
/** * Reset state of AbstractRegistryFactory */ public void reset() { f0.set(false); registries.clear(); }
3.26
dubbo_RegistryManager_getRegistries_rdh
/** * Get all registries * * @return all registries */ public Collection<Registry> getRegistries() { return Collections.unmodifiableCollection(new LinkedList<>(registries.values())); }
3.26
dubbo_RegistryManager_destroyAll_rdh
/** * Close all created registries */ public void destroyAll() { if (!f0.compareAndSet(false, true)) {return; } if (LOGGER.isInfoEnabled()) {LOGGER.info("Close all registries " + getRegistries()); } // Lock up the registry shutdown process lock.lock(); try { for (Registry registry : getRegistries()) { try {registry.destroy(); } catch (Throwable e) { LOGGER.warn(INTERNAL_ERROR, "unknown error in registry module", "", e.getMessage(), e); } } registries.clear(); } finally { // Release the lock lock.unlock(); } }
3.26
dubbo_NacosConfigServiceWrapper_handleInnerSymbol_rdh
/** * see {@link com.alibaba.nacos.client.config.utils.ParamUtils#isValid(java.lang.String)} */ private String handleInnerSymbol(String data) { if (data == null) { return null; } return data.replace(INNERCLASS_SYMBOL, INNERCLASS_COMPATIBLE_SYMBOL).replace(SLASH_CHAR, HYPHEN_CHAR);}
3.26
dubbo_AbstractInterfaceBuilder_local_rdh
/** * * @param local * @see AbstractInterfaceBuilder#stub(Boolean) * @deprecated Replace to <code>stub(Boolean)</code> */ @Deprecated public B local(Boolean local) { if (local != null) {this.local = local.toString(); } else { this.local = null; } return getThis(); }
3.26
dubbo_ConfigurableSourceBeanMetadataElement_setSource_rdh
/** * Set the source into the specified {@link BeanMetadataElement} * * @param beanMetadataElement * {@link BeanMetadataElement} instance */ default void setSource(BeanMetadataElement beanMetadataElement) { if (beanMetadataElement instanceof BeanMetadataAttributeAccessor) { ((BeanMetadataAttributeAccessor) (beanMetadataElement)).setSource(this); } }
3.26
dubbo_CallbackServiceCodec_referOrDestroyCallbackService_rdh
/** * refer or destroy callback service on server side * * @param url */ @SuppressWarnings("unchecked") private Object referOrDestroyCallbackService(Channel channel, URL url, Class<?> clazz, Invocation inv, int instid, boolean isRefer) { Object proxy; String invokerCacheKey = getServerSideCallbackInvokerCacheKey(channel, clazz.getName(), instid); String proxyCacheKey = getServerSideCallbackServiceCacheKey(channel, clazz.getName(), instid); proxy = channel.getAttribute(proxyCacheKey); String countkey = getServerSideCountKey(channel, clazz.getName()); if (isRefer) { if (proxy == null) { URL referurl = URL.valueOf((((((("callback://" + url.getAddress()) + "/") + clazz.getName()) + "?") + INTERFACE_KEY) + "=") + clazz.getName()); referurl = referurl.addParametersIfAbsent(url.getParameters()).removeParameter(METHODS_KEY).addParameter(SIDE_KEY, CONSUMER_SIDE); if (!isInstancesOverLimit(channel, referurl, clazz.getName(), instid, true)) { url.getOrDefaultApplicationModel().getDefaultModule().getServiceRepository().registerService(clazz);@SuppressWarnings("rawtypes") Invoker<?> invoker = new ChannelWrappedInvoker(clazz, channel, referurl, String.valueOf(instid)); FilterChainBuilder builder = getFilterChainBuilder(url); invoker = builder.buildInvokerChain(invoker, REFERENCE_FILTER_KEY, CommonConstants.CONSUMER); invoker = builder.buildInvokerChain(invoker, REFERENCE_FILTER_KEY, CommonConstants.CALLBACK); proxy = proxyFactory.getProxy(invoker); channel.setAttribute(proxyCacheKey, proxy); channel.setAttribute(invokerCacheKey, invoker); increaseInstanceCount(channel, countkey); // convert error fail fast . // ignore concurrent problem. Set<Invoker<?>> callbackInvokers = ((Set<Invoker<?>>) (channel.getAttribute(CHANNEL_CALLBACK_KEY))); if (callbackInvokers == null) { callbackInvokers = new ConcurrentHashSet<>(1); channel.setAttribute(CHANNEL_CALLBACK_KEY, callbackInvokers); }callbackInvokers.add(invoker); logger.info(((((("method " + RpcUtils.getMethodName(inv)) + " include a callback service :") + invoker.getUrl()) + ", a proxy :") + invoker) + " has been created."); } } } else if (proxy != null) { Invoker<?> invoker = ((Invoker<?>) (channel.getAttribute(invokerCacheKey))); try { Set<Invoker<?>> callbackInvokers = ((Set<Invoker<?>>) (channel.getAttribute(CHANNEL_CALLBACK_KEY))); if (callbackInvokers != null) { callbackInvokers.remove(invoker); } invoker.destroy(); } catch (Exception e) { logger.error(PROTOCOL_FAILED_DESTROY_INVOKER, "", "", e.getMessage(), e); } // cancel refer, directly remove from the map channel.removeAttribute(proxyCacheKey);channel.removeAttribute(invokerCacheKey); decreaseInstanceCount(channel, countkey); } return proxy; }
3.26
dubbo_CallbackServiceCodec_m0_rdh
/** * export or unexport callback service on client side * * @param channel * @param url * @param clazz * @param inst * @param export * @throws IOException */ @SuppressWarnings({ "unchecked", "rawtypes" }) private String m0(Channel channel, RpcInvocation inv, URL url, Class clazz, Object inst, Boolean export) throws IOException { int instid = System.identityHashCode(inst); Map<String, String> params = new HashMap<>(3); // no need to new client again params.put(IS_SERVER_KEY, Boolean.FALSE.toString()); // mark it's a callback, for troubleshooting params.put(IS_CALLBACK_SERVICE, Boolean.TRUE.toString()); String group = (inv == null) ? null : ((String) (inv.getObjectAttachmentWithoutConvert(GROUP_KEY))); if ((group != null) && (group.length() > 0)) { params.put(GROUP_KEY, group); } // add method, for verifying against method, automatic fallback (see dubbo protocol) params.put(METHODS_KEY, StringUtils.join(ClassUtils.getDeclaredMethodNames(clazz), ",")); Map<String, String> tmpMap = new HashMap<>(); if (url != null) { Map<String, String> parameters = url.getParameters(); if ((parameters != null) && (!parameters.isEmpty())) {tmpMap.putAll(parameters); }} tmpMap.putAll(params); tmpMap.remove(VERSION_KEY);// doesn't need to distinguish version for callback tmpMap.remove(Constants.BIND_PORT_KEY);// callback doesn't needs bind.port tmpMap.put(INTERFACE_KEY, clazz.getName()); URL exportUrl = new ServiceConfigURL(DubboProtocol.NAME, channel.getLocalAddress().getAddress().getHostAddress(), channel.getLocalAddress().getPort(), (clazz.getName() + ".") + instid, tmpMap); // no need to generate multiple exporters for different channel in the same JVM, cache key cannot collide. String cacheKey = getClientSideCallbackServiceCacheKey(instid); String countKey = getClientSideCountKey(clazz.getName()); if (export) { // one channel can have multiple callback instances, no need to re-export for different instance. if (!channel.hasAttribute(cacheKey)) { if (!isInstancesOverLimit(channel, url, clazz.getName(), instid, false)) { ModuleModel moduleModel; if (inv.getServiceModel() == null) { // TODO should get scope model from url? moduleModel = ApplicationModel.defaultModel().getDefaultModule(); logger.error(PROTOCOL_FAILED_LOAD_MODEL, "", "", ("Unable to get Service Model from Invocation. Please check if your invocation failed! " + "This error only happen in UT cases! Invocation:") + inv); } else { moduleModel = inv.getServiceModel().getModuleModel(); } ServiceDescriptor serviceDescriptor = moduleModel.getServiceRepository().registerService(clazz); ServiceMetadata serviceMetadata = new ServiceMetadata((clazz.getName() + ".") + instid, exportUrl.getGroup(), exportUrl.getVersion(), clazz); String serviceKey = BaseServiceMetadata.buildServiceKey(exportUrl.getPath(), group, exportUrl.getVersion()); ProviderModel providerModel = new ProviderModel(serviceKey, inst, serviceDescriptor, moduleModel, serviceMetadata, ClassUtils.getClassLoader(clazz)); moduleModel.getServiceRepository().registerProvider(providerModel); exportUrl = exportUrl.setScopeModel(moduleModel); exportUrl = exportUrl.setServiceModel(providerModel); Invoker<?> invoker = proxyFactory.getInvoker(inst, clazz, exportUrl); // should destroy resource? Exporter<?> exporter = f0.export(invoker); // this is used for tracing if instid has published service or not. channel.setAttribute(cacheKey, exporter); logger.info((((("Export a callback service :" + exportUrl) + ", on ") + channel) + ", url is: ") + url); increaseInstanceCount(channel, countKey); } } } else if (channel.hasAttribute(cacheKey)) { Exporter<?> exporter = ((Exporter<?>) (channel.getAttribute(cacheKey))); exporter.unexport(); channel.removeAttribute(cacheKey); decreaseInstanceCount(channel, countKey); } return String.valueOf(instid); }
3.26
dubbo_AbstractTripleReactorSubscriber_subscribe_rdh
/** * Binding the downstream, and call subscription#request(1). * * @param downstream * downstream */ public void subscribe(final CallStreamObserver<T> downstream) { if (downstream == null) { throw new NullPointerException(); } if ((this.downstream == null) && SUBSCRIBED.compareAndSet(false, true)) { this.downstream = downstream; subscription.request(1); } }
3.26
dubbo_DubboBootstrapApplicationListener_isOriginalEventSource_rdh
/** * Is original {@link ApplicationContext} as the event source * * @param event * {@link ApplicationEvent} * @return if original, return <code>true</code>, or <code>false</code> */ private boolean isOriginalEventSource(ApplicationEvent event) { boolean originalEventSource = nullSafeEquals(getApplicationContext(), event.getSource()); return originalEventSource; }
3.26
dubbo_URLParam_addParameter_rdh
/** * Add parameters to a new URLParam. * * @param key * key * @param value * value * @return A new URLParam */ public URLParam addParameter(String key, String value) { if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) { return this; } return addParameters(Collections.singletonMap(key, value)); }
3.26
dubbo_URLParam_parse_rdh
/** * Parse URLParam * Init URLParam by constructor is not allowed * * @param params * params map added into URLParam * @param rawParam * original rawParam string, directly add to rawParam field, * will not affect real key-pairs store in URLParam. * Please make sure it can correspond with params or will * cause unexpected result when calling {@link URLParam#getRawParam()} * and {@link URLParam#toString()} ()}. If you not sure, you can call * {@link URLParam#parse(String)} to init. * @return a new URLParam */ public static URLParam parse(Map<String, String> params, String rawParam) {if (CollectionUtils.isNotEmptyMap(params)) {int capacity = ((int) (params.size() / 0.75F)) + 1; BitSet keyBit = new BitSet(capacity); Map<Integer, Integer> valueMap = new HashMap<>(capacity); Map<String, String> extraParam = new HashMap<>(capacity); Map<String, Map<String, String>> methodParameters = new HashMap<>(capacity); for (Map.Entry<String, String> entry : params.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); addParameter(keyBit, valueMap, extraParam, methodParameters, key, value, false); // compatible with lower versions registering "default." keys if (key.startsWith(DEFAULT_KEY_PREFIX)) { addParameter(keyBit, valueMap, extraParam, methodParameters, key.substring(DEFAULT_KEY_PREFIX.length()), value, true); }} return new URLParam(keyBit, valueMap, extraParam, methodParameters, rawParam); } else { return EMPTY_PARAM; } }
3.26
dubbo_URLParam_addParametersIfAbsent_rdh
/** * Add absent parameters to a new URLParam. * * @param parameters * parameters in key-value pairs * @return A new URL */ public URLParam addParametersIfAbsent(Map<String, String> parameters) { if (CollectionUtils.isEmptyMap(parameters)) { return this; } return doAddParameters(parameters, true); }
3.26
dubbo_URLParam_getAnyMethodParameter_rdh
/** * Get any method related parameter which match key * * @param key * key * @return result ( if any, random choose one ) */ public String getAnyMethodParameter(String key) { Map<String, String> methodMap = f1.get(key); if (CollectionUtils.isNotEmptyMap(methodMap)) { String methods = getParameter(METHODS_KEY); if (StringUtils.isNotEmpty(methods)) { for (String method : methods.split(",")) { String value = methodMap.get(method); if (StringUtils.isNotEmpty(value)) { return value; } } } else { return methodMap.values().iterator().next(); } } return null; }
3.26
dubbo_URLParam_hasParameter_rdh
/** * check if specified key is present in URLParam * * @param key * specified key * @return present or not */ public boolean hasParameter(String key) { int keyIndex = DynamicParamTable.getKeyIndex(enableCompressed, key); if (keyIndex < 0) { return f0.containsKey(key); } return KEY.get(keyIndex); }
3.26
dubbo_URLParam_addParameterIfAbsent_rdh
/** * Add absent parameters to a new URLParam. * * @param key * key * @param value * value * @return A new URLParam */ public URLParam addParameterIfAbsent(String key, String value) { if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) { return this; } if (hasParameter(key)) { return this; } return addParametersIfAbsent(Collections.singletonMap(key, value)); }
3.26
dubbo_URLParam_addParameters_rdh
/** * Add parameters to a new URLParam. * If key-pair is present, this will cover it. * * @param parameters * parameters in key-value pairs * @return A new URLParam */ public URLParam addParameters(Map<String, String> parameters) { if (CollectionUtils.isEmptyMap(parameters)) { return this; } boolean hasAndEqual = true; Map<String, String> urlParamMap = getParameters(); for (Map.Entry<String, String> entry : parameters.entrySet()) { String value = urlParamMap.get(entry.getKey()); if (value == null) { if (entry.getValue() != null) { hasAndEqual = false; break; } } else if (!value.equals(entry.getValue())) { hasAndEqual = false; break; } } // return immediately if there's no change if (hasAndEqual) { return this; } return doAddParameters(parameters, false); }
3.26
dubbo_URLParam_removeParameters_rdh
/** * remove specified parameters in URLParam * * @param keys * keys to being removed * @return A new URLParam */ public URLParam removeParameters(String... keys) { if ((keys == null) || (keys.length == 0)) { return this; } // lazy init, null if no modify BitSet newKey = null; int[] v60 = null; Map<String, String> newExtraParams = null; Map<String, Map<String, String>> newMethodParams = null; for (String key : keys) { int keyIndex = DynamicParamTable.getKeyIndex(enableCompressed, key);if ((keyIndex >= 0) && KEY.get(keyIndex)) { if (newKey == null) { newKey = ((BitSet) (KEY.clone())); } newKey.clear(keyIndex); // which offset is in VALUE array, set value as -1, compress in the end if (v60 == null) { v60 = new int[VALUE.length]; System.arraycopy(VALUE, 0, v60, 0, VALUE.length); } // KEY is immutable v60[keyIndexToIndex(KEY, keyIndex)] = -1; } if (f0.containsKey(key)) { if (newExtraParams == null) { newExtraParams = new HashMap<>(f0); } newExtraParams.remove(key); String[] methodSplit = key.split("\\."); if (methodSplit.length == 2) { if (newMethodParams == null) { newMethodParams = new HashMap<>(f1); } Map<String, String> methodMap = newMethodParams.get(methodSplit[1]); if (CollectionUtils.isNotEmptyMap(methodMap)) { methodMap.remove(methodSplit[0]); } }} // ignore if key is absent } if (newKey == null) { newKey = KEY; } if (v60 == null) { v60 = VALUE; } else { // remove -1 value v60 = compressArray(v60); } if (newExtraParams == null) { newExtraParams = f0; } if (newMethodParams == null) { newMethodParams = f1; } if ((newKey.cardinality() + newExtraParams.size()) == 0) { // empty, directly return cache return EMPTY_PARAM; } else { return new URLParam(newKey, v60, newExtraParams, newMethodParams, null); } }
3.26
dubbo_URLParam_getParameter_rdh
/** * get value of specified key in URLParam * * @param key * specified key * @return value, null if key is absent */ public String getParameter(String key) { int keyIndex = DynamicParamTable.getKeyIndex(enableCompressed, key); if (keyIndex < 0) { return f0.get(key); }if (KEY.get(keyIndex)) { String value; int offset = keyIndexToOffset(keyIndex); value = DynamicParamTable.getValue(keyIndex, offset); return value; // if (StringUtils.isEmpty(value)) { // // Forward compatible, make sure key dynamic increment can work. // // In that case, some values which are proceed before increment will set in EXTRA_PARAMS. // return EXTRA_PARAMS.get(key); // } else { // return value; // } } return null; }
3.26
dubbo_URLParam_getMethodParameterStrict_rdh
/** * Get method related parameter. If not contains, return null. * Specially, in some situation like `method1.1.callback=true`, key is `1.callback`. * * @param method * method name * @param key * key * @return value */ public String getMethodParameterStrict(String method, String key) { String methodsString = getParameter(METHODS_KEY); if (StringUtils.isNotEmpty(methodsString)) { if (!methodsString.contains(method)) { return null; } } Map<String, String> methodMap = f1.get(key); if (CollectionUtils.isNotEmptyMap(methodMap)) { return methodMap.get(method); } else { return null; } }
3.26
dubbo_URLParam_getRawParam_rdh
/** * get raw string like parameters * * @return raw string like parameters */ public String getRawParam() { if (StringUtils.isNotEmpty(rawParam)) {return rawParam; } else { // empty if parameters have been modified or init by Map return toString(); } }
3.26
dubbo_URLParam_getMethodParameter_rdh
/** * Get method related parameter. If not contains, use getParameter(key) instead. * Specially, in some situation like `method1.1.callback=true`, key is `1.callback`. * * @param method * method name * @param key * key * @return value */ public String getMethodParameter(String method, String key) { String strictResult = getMethodParameterStrict(method, key); return StringUtils.isNotEmpty(strictResult) ? strictResult : getParameter(key); }
3.26
dubbo_URLParam_getParameters_rdh
/** * Get a Map like URLParam * * @return a {@link URLParamMap} adapt to URLParam */ public Map<String, String> getParameters() { return new URLParamMap(this); }
3.26
dubbo_ThreadLocalCache_get_rdh
/** * API to return stored value using a key against the calling thread specific store. * * @param key * Unique identifier for cache lookup * @return Return stored object against key */ @Override public Object get(Object key) { return store.get().get(key); }
3.26
dubbo_ThreadLocalCache_put_rdh
/** * API to store value against a key in the calling thread scope. * * @param key * Unique identifier for the object being store. * @param value * Value getting store */ @Override public void put(Object key, Object value) { store.get().put(key, value); }
3.26
dubbo_HeaderExchangeServer_calculateLeastDuration_rdh
/** * Each interval cannot be less than 1000ms. */ private long calculateLeastDuration(int time) { if ((time / HEARTBEAT_CHECK_TICK) <= 0) { return LEAST_HEARTBEAT_DURATION; } else { return time / HEARTBEAT_CHECK_TICK; } }
3.26
dubbo_HttpMessageCodecManager_typeJudge_rdh
/** * if content-type is null or all ,will judge media type by class type * * @param mediaType * @param bodyType * @param httpMessageCodec * @return */ private static boolean typeJudge(MediaType mediaType, Class<?> bodyType, HttpMessageCodec httpMessageCodec) { return ((MediaType.ALL_VALUE.equals(mediaType) || (mediaType == null)) && (bodyType != null)) && httpMessageCodec.typeSupport(bodyType); }
3.26
dubbo_SingleRouterChain_initWithRouters_rdh
/** * the resident routers must being initialized before address notification. * only for ut */ public void initWithRouters(List<Router> builtinRouters) { this.builtinRouters = builtinRouters; this.routers = new LinkedList<>(builtinRouters);}
3.26
dubbo_SingleRouterChain_setInvokers_rdh
/** * Notify router chain of the initial addresses from registry at the first time. * Notify whenever addresses in registry change. */ public void setInvokers(BitList<Invoker<T>> invokers) { this.invokers = (invokers == null) ? BitList.emptyList() : invokers; f1.forEach(router -> router.notify(this.invokers)); stateRouters.forEach(router -> router.notify(this.invokers)); }
3.26
dubbo_SingleRouterChain_printRouterSnapshot_rdh
/** * store each router's input and output, log out if empty */ private void printRouterSnapshot(URL url, BitList<Invoker<T>> availableInvokers, Invocation invocation) { if (logger.isWarnEnabled()) { logRouterSnapshot(url, invocation, buildRouterSnapshot(url, availableInvokers, invocation)); } }
3.26
dubbo_SingleRouterChain_buildRouterSnapshot_rdh
/** * Build each router's result */ public RouterSnapshotNode<T> buildRouterSnapshot(URL url, BitList<Invoker<T>> availableInvokers, Invocation invocation) { BitList<Invoker<T>> resultInvokers = availableInvokers.clone();RouterSnapshotNode<T> parentNode = new RouterSnapshotNode<T>("Parent", resultInvokers.clone()); parentNode.setNodeOutputInvokers(resultInvokers.clone());// 1. route state router Holder<RouterSnapshotNode<T>> nodeHolder = new Holder<>(); nodeHolder.set(parentNode); resultInvokers = headStateRouter.route(resultInvokers, url, invocation, true, nodeHolder); // result is empty, log out if (f1.isEmpty() || (resultInvokers.isEmpty() && shouldFailFast)) { parentNode.setChainOutputInvokers(resultInvokers.clone()); return parentNode; } RouterSnapshotNode<T> v12 = new RouterSnapshotNode<T>("CommonRouter", resultInvokers.clone()); parentNode.appendNode(v12); List<Invoker<T>> commonRouterResult = resultInvokers; // 2. route common router for (Router router : f1) {// Copy resultInvokers to a arrayList. BitList not support List<Invoker<T>> inputInvokers = new ArrayList<>(commonRouterResult);RouterSnapshotNode<T> currentNode = new RouterSnapshotNode<T>(router.getClass().getSimpleName(), inputInvokers); // append to router node chain v12.appendNode(currentNode); v12 = currentNode; RouterResult<Invoker<T>> routeStateResult = router.route(inputInvokers, url, invocation, true); List<Invoker<T>> routeResult = routeStateResult.getResult(); String routerMessage = routeStateResult.getMessage(); currentNode.setNodeOutputInvokers(routeResult); currentNode.setRouterMessage(routerMessage); commonRouterResult = routeResult; // result is empty, log out if (CollectionUtils.isEmpty(routeResult) && shouldFailFast) { break; } if (!routeStateResult.isNeedContinueRoute()) { break; } } v12.setChainOutputInvokers(v12.getNodeOutputInvokers()); // 3. set router chain output reverse RouterSnapshotNode<T> currentNode = v12; while (currentNode != null) {RouterSnapshotNode<T> parent = currentNode.getParentNode(); if (parent != null) { // common router only has one child invoke parent.setChainOutputInvokers(currentNode.getChainOutputInvokers()); } currentNode = parent; } return parentNode; }
3.26
dubbo_SingleRouterChain_addRouters_rdh
/** * If we use route:// protocol in version before 2.7.0, each URL will generate a Router instance, so we should * keep the routers up to date, that is, each time router URLs changes, we should update the routers list, only * keep the builtinRouters which are available all the time and the latest notified routers which are generated * from URLs. * * @param routers * routers from 'router://' rules in 2.6.x or before. */ public void addRouters(List<Router> routers) { List<Router> newRouters = new LinkedList<>(); newRouters.addAll(builtinRouters); newRouters.addAll(routers); CollectionUtils.sort(newRouters); this.routers = newRouters; }
3.26
dubbo_SingleRouterChain_setHeadStateRouter_rdh
/** * for uts only */ @Deprecated public void setHeadStateRouter(StateRouter<T> headStateRouter) { this.headStateRouter = headStateRouter; }
3.26
dubbo_ThrowableConsumer_execute_rdh
/** * Executes {@link ThrowableConsumer} * * @param t * the function argument * @param consumer * {@link ThrowableConsumer} * @param <T> * the source type */ static <T> void execute(T t, ThrowableConsumer<T> consumer) { consumer.execute(t); }
3.26
dubbo_ModuleServiceRepository_registerService_rdh
/** * See {@link #registerService(Class)} * <p> * we assume: * 1. services with different interfaces are not allowed to have the same path. * 2. services share the same interface but has different group/version can share the same path. * 3. path's default value is the name of the interface. * * @param path * @param interfaceClass * @return */ public ServiceDescriptor registerService(String path, Class<?> interfaceClass) { ServiceDescriptor serviceDescriptor = registerService(interfaceClass); // if path is different with interface name, add extra path mapping if (!interfaceClass.getName().equals(path)) { List<ServiceDescriptor> serviceDescriptors = ConcurrentHashMapUtils.computeIfAbsent(services, path, _k -> new CopyOnWriteArrayList<>()); synchronized(serviceDescriptors) { Optional<ServiceDescriptor> previous = serviceDescriptors.stream().filter(s -> s.getServiceInterfaceClass().equals(serviceDescriptor.getServiceInterfaceClass())).findFirst(); if (previous.isPresent()) { return previous.get(); } else { serviceDescriptors.add(serviceDescriptor); return serviceDescriptor; } } } return serviceDescriptor; }
3.26
dubbo_ModuleServiceRepository_registerConsumer_rdh
/** * * @deprecated Replaced to {@link ModuleServiceRepository#registerConsumer(ConsumerModel)} */ @Deprecated public void registerConsumer(String serviceKey, ServiceDescriptor serviceDescriptor, ReferenceConfigBase<?> rc, Object proxy, ServiceMetadata serviceMetadata) { ClassLoader classLoader = null; if (rc != null) { classLoader = rc.getInterfaceClassLoader(); } ConsumerModel consumerModel = new ConsumerModel(serviceMetadata.getServiceKey(), proxy, serviceDescriptor, serviceMetadata, null, classLoader); this.registerConsumer(consumerModel); }
3.26
dubbo_ModuleServiceRepository_lookupReferredService_rdh
/** * * @deprecated Replaced to {@link ModuleServiceRepository#lookupReferredServices(String)} */ @Deprecated public ConsumerModel lookupReferredService(String serviceKey) { if (consumers.containsKey(serviceKey)) { List<ConsumerModel> consumerModels = consumers.get(serviceKey); return consumerModels.size() > 0 ? consumerModels.get(0) : null; } else { return null; } }
3.26
dubbo_ModuleServiceRepository_registerProvider_rdh
/** * * @deprecated Replaced to {@link ModuleServiceRepository#registerProvider(ProviderModel)} */ @Deprecated public void registerProvider(String serviceKey, Object serviceInstance, ServiceDescriptor serviceModel, ServiceConfigBase<?> serviceConfig, ServiceMetadata serviceMetadata) { ClassLoader classLoader = null; Class<?> cla = null; if (serviceConfig != null) { classLoader = serviceConfig.getInterfaceClassLoader(); cla = serviceConfig.getInterfaceClass(); } ProviderModel providerModel = new ProviderModel(serviceKey, serviceInstance, serviceModel, serviceMetadata, classLoader); this.registerProvider(providerModel); }
3.26
dubbo_ProtocolConfig_getDispather_rdh
/** * typo, switch to use {@link #getDispatcher()} * * @deprecated {@link #getDispatcher()} */ @Deprecated @Parameter(excluded = true, attribute = false) public String getDispather() { return m5(); }
3.26
dubbo_MeshRuleRouter_getRemoteAppName_rdh
/** * for ut only */ @Deprecated public Set<String> getRemoteAppName() { return remoteAppName; }
3.26
dubbo_MeshRuleRouter_getInvokerList_rdh
/** * for ut only */ @Deprecated public BitList<Invoker<T>> getInvokerList() { return invokerList; }
3.26
dubbo_MeshRuleRouter_computeDestination_rdh
/** * Compute Destination Subset */ protected String computeDestination(MeshRuleCache<T> meshRuleCache, String appName, DubboDestination dubboDestination, BitList<Invoker<T>> availableInvokers) throws RpcException { String subset = dubboDestination.getSubset(); do { BitList<Invoker<T>> result = meshRuleCache.getSubsetInvokers(appName, subset); if (CollectionUtils.isNotEmpty(result) && (!availableInvokers.clone().and(result).isEmpty())) { return subset;} // fall back DubboRouteDestination dubboRouteDestination = dubboDestination.getFallback(); if (dubboRouteDestination == null) { break; } dubboDestination = dubboRouteDestination.getDestination(); if (dubboDestination == null) { break; } subset = dubboDestination.getSubset(); } while (true ); return null; }
3.26
dubbo_MeshRuleRouter_getDubboRoute_rdh
/** * Match virtual service (by serviceName) */ protected DubboRoute getDubboRoute(VirtualServiceRule virtualServiceRule, Invocation invocation) {String v10 = invocation.getServiceName(); VirtualServiceSpec spec = virtualServiceRule.getSpec(); List<DubboRoute> dubboRouteList = spec.getDubbo(); if (CollectionUtils.isNotEmpty(dubboRouteList)) { for (DubboRoute dubboRoute : dubboRouteList) { List<StringMatch> stringMatchList = dubboRoute.getServices(); if (CollectionUtils.isEmpty(stringMatchList)) { return dubboRoute; } for (StringMatch stringMatch : stringMatchList) { if (stringMatch.isMatch(v10)) { return dubboRoute; } } } } return null; }
3.26
dubbo_MeshRuleRouter_randomSelectDestination_rdh
/** * Find out target invokers from RouteDestination */ protected String randomSelectDestination(MeshRuleCache<T> meshRuleCache, String appName, List<DubboRouteDestination> routeDestination, BitList<Invoker<T>> availableInvokers) throws RpcException { // randomly select one DubboRouteDestination from list by weight int totalWeight = 0; for (DubboRouteDestination dubboRouteDestination : routeDestination) { totalWeight += Math.max(dubboRouteDestination.getWeight(), 1); } int target = ThreadLocalRandom.current().nextInt(totalWeight); for (DubboRouteDestination destination : routeDestination) { target -= Math.max(destination.getWeight(), 1); if (target <= 0) { // match weight String result = computeDestination(meshRuleCache, appName, destination.getDestination(), availableInvokers); if (result != null) { return result; } } } // fall back for (DubboRouteDestination destination : routeDestination) { String result = computeDestination(meshRuleCache, appName, destination.getDestination(), availableInvokers); if (result != null) { return result; } } return null; }
3.26
dubbo_MeshRuleRouter_getDubboRouteDestination_rdh
/** * Match route detail (by params) */ protected List<DubboRouteDestination> getDubboRouteDestination(DubboRoute dubboRoute, Invocation invocation) { List<DubboRouteDetail> dubboRouteDetailList = dubboRoute.getRoutedetail(); if (CollectionUtils.isNotEmpty(dubboRouteDetailList)) { for (DubboRouteDetail dubboRouteDetail : dubboRouteDetailList) { List<DubboMatchRequest> matchRequestList = dubboRouteDetail.getMatch(); if (CollectionUtils.isEmpty(matchRequestList)) { return dubboRouteDetail.getRoute(); } if (matchRequestList.stream().allMatch(request -> request.isMatch(invocation, sourcesLabels, tracingContextProviders))) { return dubboRouteDetail.getRoute(); } } } return null; }
3.26
dubbo_MeshRuleRouter_getMeshRuleCache_rdh
/** * for ut only */ @Deprecated public MeshRuleCache<T> getMeshRuleCache() {return meshRuleCache; }
3.26
dubbo_FrameworkModelCleaner_destroyProtocols_rdh
/** * Destroy all the protocols. */ private void destroyProtocols(FrameworkModel frameworkModel) { if (protocolDestroyed.compareAndSet(false, true)) { ExtensionLoader<Protocol> loader = frameworkModel.getExtensionLoader(Protocol.class);for (String protocolName : loader.getLoadedExtensions()) { try { Protocol protocol = loader.getLoadedExtension(protocolName); if (protocol != null) { protocol.destroy(); } } catch (Throwable t) { logger.warn(CONFIG_UNDEFINED_PROTOCOL, "", "", t.getMessage(), t); } } } }
3.26
dubbo_DefaultModuleDeployer_prepare_rdh
/** * Prepare for export/refer service, trigger initializing application and module */ @Overridepublic void prepare() { applicationDeployer.initialize(); this.initialize(); }
3.26
dubbo_RdsRouteRuleManager_getRuleListeners_rdh
// for test static ConcurrentHashMap<String, Set<XdsRouteRuleListener>> getRuleListeners() { return RULE_LISTENERS; }
3.26
dubbo_ScopeModel_getDesc_rdh
/** * * @return to describe string of this scope model */ public String getDesc() { if (this.desc == null) { this.desc = buildDesc(); } return this.desc; }
3.26
dubbo_ScopeModel_initialize_rdh
/** * NOTE: * <ol> * <li>The initialize method only be called in subclass.</li> * <li> * In subclass, the extensionDirector and beanFactory are available in initialize but not available in constructor. * </li> * </ol> */ protected void initialize() { synchronized(instLock) { this.extensionDirector = new ExtensionDirector(parent != null ? parent.getExtensionDirector() : null, scope, this); this.extensionDirector.addExtensionPostProcessor(new ScopeModelAwareExtensionProcessor(this)); this.beanFactory = new ScopeBeanFactory(parent != null ? parent.getBeanFactory() : null, extensionDirector); // Add Framework's ClassLoader by default ClassLoader dubboClassLoader = ScopeModel.class.getClassLoader(); if (dubboClassLoader != null) { this.addClassLoader(dubboClassLoader);} } }
3.26
dubbo_ScopeModel_getModelEnvironment_rdh
/** * Get current model's environment. * * @see <a href="https://github.com/apache/dubbo/issues/12542">Configuration refresh issue</a> * @deprecated use modelEnvironment() instead */ @Deprecated public final Environment getModelEnvironment() { try { return modelEnvironment(); } catch (Exception ex) { return null; } }
3.26
dubbo_DubboRelaxedBindingAutoConfiguration_dubboBasePackages_rdh
/** * The bean is used to scan the packages of Dubbo Service classes * * @param environment * {@link Environment} instance * @return non-null {@link Set} * @since 2.7.8 */ @ConditionalOnMissingBean(name = BASE_PACKAGES_BEAN_NAME) @Bean(name = BASE_PACKAGES_BEAN_NAME) public Set<String> dubboBasePackages(Environment environment) { PropertyResolver propertyResolver = dubboScanBasePackagesPropertyResolver(environment); return propertyResolver.getProperty(BASE_PACKAGES_PROPERTY_NAME, Set.class, emptySet()); }
3.26
dubbo_ServiceDiscovery_isAvailable_rdh
/** * Get services is the default way for service discovery to be available */ default boolean isAvailable() { return (!isDestroy()) && CollectionUtils.isNotEmpty(getServices()); }
3.26
dubbo_ServiceDiscovery_removeServiceInstancesChangedListener_rdh
/** * unsubscribe to instance change event. * * @param listener * @throws IllegalArgumentException */ default void removeServiceInstancesChangedListener(ServiceInstancesChangedListener listener) throws IllegalArgumentException { }
3.26
dubbo_ReactorServerCalls_oneToMany_rdh
/** * Implements a unary -> stream call as Mono -> Flux * * @param request * request * @param responseObserver * response StreamObserver * @param func * service implementation */ public static <T, R> void oneToMany(T request, StreamObserver<R> responseObserver, Function<Mono<T>, Flux<R>> func) { try { Flux<R> response = func.apply(Mono.just(request)); ServerTripleReactorSubscriber<R> subscriber = response.subscribeWith(new ServerTripleReactorSubscriber<>()); subscriber.subscribe(((ServerCallToObserverAdapter<R>) (responseObserver))); } catch (Throwable throwable) { responseObserver.onError(throwable); } }
3.26
dubbo_ReactorServerCalls_manyToOne_rdh
/** * Implements a stream -> unary call as Flux -> Mono * * @param responseObserver * response StreamObserver * @param func * service implementation * @return request StreamObserver */ public static <T, R> StreamObserver<T> manyToOne(StreamObserver<R> responseObserver, Function<Flux<T>, Mono<R>> func) { ServerTripleReactorPublisher<T> v2 = new ServerTripleReactorPublisher<T>(((CallStreamObserver<R>) (responseObserver)));try { Mono<R> responseMono = func.apply(Flux.from(v2)); responseMono.subscribe(value -> { // Don't try to respond if the server has already canceled the request if (!v2.isCancelled()) { responseObserver.onNext(value); } }, throwable -> { // Don't try to respond if the server has already canceled the request if (!v2.isCancelled()) { responseObserver.onError(throwable); } }, responseObserver::onCompleted); v2.startRequest(); } catch (Throwable throwable) { responseObserver.onError(throwable); } return v2; }
3.26
dubbo_ReactorServerCalls_oneToOne_rdh
/** * Implements a unary -> unary call as Mono -> Mono * * @param request * request * @param responseObserver * response StreamObserver * @param func * service implementation */ public static <T, R> void oneToOne(T request, StreamObserver<R> responseObserver, Function<Mono<T>, Mono<R>> func) { func.apply(Mono.just(request)).subscribe(res -> { CompletableFuture.completedFuture(res).whenComplete((r, t) -> { if (t != null) { responseObserver.onError(t); } else { responseObserver.onNext(r); responseObserver.onCompleted(); } }); }); }
3.26
dubbo_ReactorServerCalls_manyToMany_rdh
/** * Implements a stream -> stream call as Flux -> Flux * * @param responseObserver * response StreamObserver * @param func * service implementation * @return request StreamObserver */ public static <T, R> StreamObserver<T> manyToMany(StreamObserver<R> responseObserver, Function<Flux<T>, Flux<R>> func) { // responseObserver is also a subscription of publisher, we can use it to request more data ServerTripleReactorPublisher<T> serverPublisher = new ServerTripleReactorPublisher<T>(((CallStreamObserver<R>) (responseObserver))); try { Flux<R> responseFlux = func.apply(Flux.from(serverPublisher)); ServerTripleReactorSubscriber<R> serverSubscriber = responseFlux.subscribeWith(new ServerTripleReactorSubscriber<>()); serverSubscriber.subscribe(((CallStreamObserver<R>) (responseObserver))); serverPublisher.startRequest(); } catch (Throwable throwable) { responseObserver.onError(throwable); } return serverPublisher; }
3.26
dubbo_PojoUtils_getKeyTypeForMap_rdh
/** * Get key type for {@link Map} directly implemented by {@code clazz}. * If {@code clazz} does not implement {@link Map} directly, return {@code null}. * * @param clazz * {@link Class} * @return Return String.class for {@link com.alibaba.fastjson.JSONObject} */private static Type getKeyTypeForMap(Class<?> clazz) { Type[] interfaces = clazz.getGenericInterfaces(); if (!ArrayUtils.isEmpty(interfaces)) { for (Type type : interfaces) { if (type instanceof ParameterizedType) { ParameterizedType t = ((ParameterizedType) (type)); if ("java.util.Map".equals(t.getRawType().getTypeName())) { return t.getActualTypeArguments()[0]; } } } } return null; }
3.26
dubbo_PojoUtils_mapToPojo_rdh
/** * convert map to a specific class instance * * @param map * map wait for convert * @param cls * the specified class * @param <T> * the type of {@code cls} * @return class instance declare in param {@code cls} * @throws ReflectiveOperationException * if the instance creation is failed * @since 2.7.10 */ public static <T> T mapToPojo(Map<String, Object> map, Class<T> cls) throws ReflectiveOperationException { T instance = cls.getDeclaredConstructor().newInstance(); Map<String, Field> beanPropertyFields = ReflectUtils.getBeanPropertyFields(cls); for (Map.Entry<String, Field> entry : beanPropertyFields.entrySet()) { String name = entry.getKey(); Field field = entry.getValue(); Object mapObject = map.get(name); if (mapObject == null) { continue; } Type type = field.getGenericType(); Object fieldObject = getFieldObject(mapObject, type); field.set(instance, fieldObject); } return instance; }
3.26
dubbo_PojoUtils_getGenericClassByIndex_rdh
/** * Get parameterized type * * @param genericType * generic type * @param index * index of the target parameterized type * @return Return Person.class for List<Person>, return Person.class for Map<String, Person> when index=0 */ private static Type getGenericClassByIndex(Type genericType, int index) { Type clazz = null; // find parameterized type if (genericType instanceof ParameterizedType) { ParameterizedType t = ((ParameterizedType) (genericType)); Type[] types = t.getActualTypeArguments(); clazz = types[index]; } return clazz; }
3.26
dubbo_PojoUtils_getDefaultValue_rdh
/** * return init value * * @param parameterType * @return */ private static Object getDefaultValue(Class<?> parameterType) { if ("char".equals(parameterType.getName())) { return Character.MIN_VALUE; } if ("boolean".equals(parameterType.getName())) { return false; } if ("byte".equals(parameterType.getName())) { return ((byte) (0)); } if ("short".equals(parameterType.getName())) { return ((short) (0)); } return parameterType.isPrimitive() ? 0 : null; }
3.26
dubbo_PojoUtils_updatePropertyIfAbsent_rdh
/** * Update the property if absent * * @param getterMethod * the getter method * @param setterMethod * the setter method * @param newValue * the new value * @param <T> * the value type * @since 2.7.8 */ public static <T> void updatePropertyIfAbsent(Supplier<T> getterMethod, Consumer<T> setterMethod, T newValue) { if ((newValue != null) && (getterMethod.get() == null)) { setterMethod.accept(newValue); } }
3.26
dubbo_AbstractServiceRestMetadataResolver_postProcessRestMethodMetadata_rdh
/** * Post-Process for {@link RestMethodMetadata}, sub-type could override this method for further works * * @param processingEnv * {@link ProcessingEnvironment} * @param serviceType * The type that @Service annotated * @param method * The public method of <code>serviceType</code> * @param metadata * {@link RestMethodMetadata} maybe updated */ protected void postProcessRestMethodMetadata(ProcessingEnvironment processingEnv, TypeElement serviceType, ExecutableElement method, RestMethodMetadata metadata) { }
3.26
dubbo_AbstractServiceRestMetadataResolver_findRestCapableMethod_rdh
/** * Find the method with the capable for REST from the specified service method and its override method * * @param processingEnv * {@link ProcessingEnvironment} * @param serviceType * @param serviceInterfaceType * @param serviceMethod * @return <code>null</code> if can't be found */ private ExecutableElement findRestCapableMethod(ProcessingEnvironment processingEnv, TypeElement serviceType, TypeElement serviceInterfaceType, ExecutableElement serviceMethod) { // try to judge the override first ExecutableElement overrideMethod = getOverrideMethod(processingEnv, serviceType, serviceMethod); if (supports(processingEnv, serviceType, serviceInterfaceType, overrideMethod)) { return overrideMethod; } // or, try to judge the declared method return supports(processingEnv, serviceType, serviceInterfaceType, serviceMethod) ? serviceMethod : null; } /** * Does the specified method support REST or not ? * * @param processingEnv * {@link ProcessingEnvironment}
3.26
dubbo_Configurator_toConfigurators_rdh
/** * Convert override urls to map for use when re-refer. Send all rules every time, the urls will be reassembled and * calculated * * URL contract: * <ol> * <li>override://0.0.0.0/...( or override://ip:port...?anyhost=true)&para1=value1... means global rules * (all of the providers take effect)</li> * <li>override://ip:port...?anyhost=false Special rules (only for a certain provider)</li> * <li>override:// rule is not supported... ,needs to be calculated by registry itself</li> * <li>override://0.0.0.0/ without parameters means clearing the override</li> * </ol> * * @param urls * URL list to convert * @return converted configurator list */ static Optional<List<Configurator>> toConfigurators(List<URL> urls) {if (CollectionUtils.isEmpty(urls)) { return Optional.empty(); } ConfiguratorFactory configuratorFactory = urls.get(0).getOrDefaultApplicationModel().getExtensionLoader(ConfiguratorFactory.class).getAdaptiveExtension(); List<Configurator> configurators = new ArrayList<>(urls.size()); for (URL url : urls) { if (EMPTY_PROTOCOL.equals(url.getProtocol())) { configurators.clear(); break; } Map<String, String> override = new HashMap<>(url.getParameters()); // The anyhost parameter of override may be added automatically, it can't change the judgement of changing // url override.remove(ANYHOST_KEY); if (CollectionUtils.isEmptyMap(override)) { continue; } configurators.add(configuratorFactory.getConfigurator(url)); } Collections.sort(configurators); return Optional.of(configurators); }
3.26