name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
hmily_LogUtil_error_rdh
/** * Error. * * @param logger * the logger * @param supplier * the supplier */ public static void error(final Logger logger, final Supplier<Object> supplier) { if (logger.isErrorEnabled()) { logger.error(Objects.toString(supplier.get())); } }
3.26
hmily_LogUtil_debug_rdh
/** * Debug. * * @param logger * the logger * @param supplier * the supplier */ public static void debug(final Logger logger, final Supplier<Object> supplier) { if (logger.isDebugEnabled()) { logger.debug(Objects.toString(supplier.get())); } }
3.26
hmily_MetricsTrackerFacade_start_rdh
/** * Init for metrics tracker manager. * * @param metricsConfig * metrics config */ public void start(final HmilyMetricsConfig metricsConfig) { if (this.isStarted.compareAndSet(false, true)) { metricsBootService = ExtensionLoaderFactory.load(MetricsBootService.class, metricsConfig.getMetricsName()); Preconditions.checkNotNull(metricsBootService, "Can not find metrics tracker manager with metrics name : %s in metrics configuration.", metricsConfig.getMetricsName()); metricsBootService.start(metricsConfig, ExtensionLoaderFactory.load(MetricsRegister.class, metricsConfig.getMetricsName())); } else { log.info("metrics tracker has started !"); } }
3.26
hmily_HmilyXaTransactionManager_setTxTotr_rdh
/** * tx to threadLocal. */ private void setTxTotr(final Transaction transaction) { synchronized(tms) { Stack<Transaction> v19 = tms.get(); if (v19 == null) { v19 = new Stack<>(); tms.set(v19); } v19.push(transaction); } }
3.26
hmily_HmilyXaTransactionManager_getState_rdh
/** * Gets state. * * @return the state * @throws SystemException * the system exception */ public Integer getState() throws SystemException { Transaction v16 = getTransaction(); if (v16 == null) { return XaState.STATUS_NO_TRANSACTION.getState(); } return v16.getStatus(); }
3.26
hmily_HmilyXaTransactionManager_initialized_rdh
/** * Initialized hmily xa transaction manager. * * @return the hmily xa transaction manager */ public static HmilyXaTransactionManager initialized() {return new HmilyXaTransactionManager(); }
3.26
hmily_HmilyXaTransactionManager_getThreadTransaction_rdh
/** * Gets thread transaction. * * @return the thread transaction */ public Transaction getThreadTransaction() { synchronized(tms) { Stack<Transaction> stack = tms.get();if (stack == null) { return null; } return stack.peek(); } }
3.26
hmily_HmilyXaTransactionManager_markTransactionRollback_rdh
/** * 把事务标记为回滚状态. * * @param transId * 事务id. */ public void markTransactionRollback(final String transId) { if (transactionMap.containsKey(transId)) { logger.warn("When rollback cmd is received, the business logic of transaction {} isn't stopped, " + "maybe there is a RPC timout.", transId); try { transactionMap.get(transId).setRollbackOnly(); } catch (SystemException e) { logger.error("err setRollbackOnly", e); } } }
3.26
hmily_HmilyMetaDataManager_register_rdh
/** * Register hmily metadata. * * @param hmilyTacResource * the hmily resource * @param databaseType * database type */ public static void register(final HmilyTacResource hmilyTacResource, final DatabaseType databaseType) { DataSourceMetaData dataSourceMetaData; try { dataSourceMetaData = DataSourceMetaDataLoader.load(hmilyTacResource.getTargetDataSource(), databaseType); } catch (final SQLException ex) { throw new IllegalStateException("failed in loading datasource metadata into hmily"); }DATASOURCE_META_CACHE.put(hmilyTacResource.getResourceId(), dataSourceMetaData); }
3.26
hmily_HmilyMetaDataManager_get_rdh
/** * Get data source meta data. * * @param resourceId * the resource id * @return data source metadata */ public static DataSourceMetaData get(final String resourceId) { return DATASOURCE_META_CACHE.get(resourceId); }
3.26
hmily_TransactionImpl_doDeList_rdh
/** * Do de list. * * @param flag * the flag * @throws SystemException * the system exception */ public void doDeList(final int flag) throws SystemException { delistResourceList = new ArrayList<>(enlistResourceList); for (XAResource resource : delistResourceList) { delistResource(resource, flag); } }
3.26
hmily_TransactionImpl_getContext_rdh
/** * Gets context. * * @return the context */ public TransactionContext getContext() { return context; }
3.26
hmily_TransactionImpl_createSubTransaction_rdh
/** * 创建一个子任务. * * @return the transaction */public TransactionImpl createSubTransaction() {return new TransactionImpl(this); }
3.26
hmily_TransactionImpl_getXid_rdh
/** * Gets xid. * * @return the xid */ public XidImpl getXid() { return f0; }
3.26
hmily_TransactionImpl_doEnList_rdh
/** * Do en list. * * @param xaResource * the xa resource * @param flag * the flag * @throws SystemException * the system exception * @throws RollbackException * the rollback exception */ public void doEnList(final XAResource xaResource, final int flag) throws SystemException, RollbackException { // xaResource; if ((flag == XAResource.TMJOIN) || (flag == XAResource.TMNOFLAGS)) { // 这里需要处理不同的xa事务数据. enlistResource(xaResource); } else if (flag == XAResource.TMRESUME) { // 进行事务的恢复. if (delistResourceList != null) { for (final XAResource v1 : delistResourceList) { this.enlistResource(v1); } } } delistResourceList = null; }
3.26
hmily_SelectStatementAssembler_assembleHmilySelectStatement_rdh
/** * Assemble Hmily select statement. * * @param selectStatement * select statement * @param hmilySelectStatement * hmily select statement * @return hmily select statement */ public static HmilySelectStatement assembleHmilySelectStatement(final SelectStatement selectStatement, final HmilySelectStatement hmilySelectStatement) { HmilySimpleTableSegment hmilySimpleTableSegment = CommonAssembler.assembleHmilySimpleTableSegment(((SimpleTableSegment) (selectStatement.getFrom()))); HmilyWhereSegment hmilyWhereSegment = null; if (selectStatement.getWhere().isPresent()) { hmilyWhereSegment = assembleHmilyWhereSegment(selectStatement.getWhere().get()); } hmilySelectStatement.setTableSegment(hmilySimpleTableSegment); hmilySelectStatement.setWhere(hmilyWhereSegment); HmilyOrderBySegment hmilyOrderBySegment = null; if (selectStatement.getOrderBy().isPresent()) { hmilyOrderBySegment = assembleHmilyOrderBySegment(selectStatement.getOrderBy().get()); } hmilySelectStatement.setOrderBy(hmilyOrderBySegment); return hmilySelectStatement; }
3.26
hmily_HmilyParticipantUndoCacheManager_get_rdh
/** * acquire hmilyTransaction. * * @param participantId * this guava key. * @return {@linkplain HmilyTransaction} */ public List<HmilyParticipantUndo> get(final Long participantId) { try { return loadingCache.get(participantId); } catch (ExecutionException e) { return Collections.emptyList(); } }
3.26
hmily_HmilyParticipantUndoCacheManager_cacheHmilyParticipantUndo_rdh
/** * Cache hmily participant undo. * * @param participantId * the participant id * @param hmilyParticipantUndo * the hmily participant undo */ public void cacheHmilyParticipantUndo(final Long participantId, final HmilyParticipantUndo hmilyParticipantUndo) { List<HmilyParticipantUndo> existList = get(participantId); if (CollectionUtils.isEmpty(existList)) { loadingCache.put(participantId, Lists.newArrayList(hmilyParticipantUndo)); } else { existList.add(hmilyParticipantUndo); loadingCache.put(participantId, existList); } }
3.26
hmily_HmilyParticipantUndoCacheManager_removeByKey_rdh
/** * remove guava cache by key. * * @param participantId * guava cache key. */ public void removeByKey(final Long participantId) { if (Objects.nonNull(participantId)) { loadingCache.invalidate(participantId); } }
3.26
hmily_SQLImageMapperFactory_newInstance_rdh
/** * Create new instance of SQL image mapper. * * @param sqlTuple * SQL tuple * @return SQL image mapper */ public static SQLImageMapper newInstance(final HmilySQLTuple sqlTuple) { switch (sqlTuple.getManipulationType()) { case INSERT : return new InsertSQLImageMapper(sqlTuple.getTableName(), sqlTuple.getAfterImage()); case UPDATE : return new UpdateSQLImageMapper(sqlTuple.getTableName(), sqlTuple.getBeforeImage(), sqlTuple.getAfterImage()); case DELETE : return new DeleteSQLImageMapper(sqlTuple.getTableName(), sqlTuple.getBeforeImage()); default : throw new SQLRevertException(String.format("unsupported SQL manipulate type [%s]", sqlTuple.getManipulationType())); } }
3.26
hmily_XaResourcePool_removeResource_rdh
/** * Remove resource xa resource wrapped. * * @param xid * the xid * @return the xa resource wrapped */ public XaResourceWrapped removeResource(final Xid xid) { String gid = new String(xid.getGlobalTransactionId()); if (xids.containsKey(gid)) { xids.get(gid).remove(xid); } return pool.remove(xid); }
3.26
hmily_XaResourcePool_addResource_rdh
/** * Add resource. * * @param xid * the xid * @param xaResourceWrapped * the xa resource wrapped */ public synchronized void addResource(final Xid xid, final XaResourceWrapped xaResourceWrapped) { pool.put(xid, xaResourceWrapped); // 处理一下xid; String globalId = new String(xid.getGlobalTransactionId()); Set<Xid> xids = this.xids.get(globalId); if (xids == null) { xids = new HashSet<>(); } xids.add(xid); this.xids.put(globalId, xids); }
3.26
hmily_XaResourcePool_getResource_rdh
/** * Gets resource. * * @param xid * the xid * @return the resource */ public XaResourceWrapped getResource(final Xid xid) { XaResourceWrapped xaResourceWrapped = pool.get(xid); // if (xaResourceWrapped == null) { // //todo:从日志中查找. // } return xaResourceWrapped; }
3.26
hmily_XaResourcePool_getAllResource_rdh
/** * Gets all resource. * * @param globalId * the global id * @return the all resource */ public List<XaResourceWrapped> getAllResource(final String globalId) { Set<Xid> xids = this.xids.get(globalId); if (xids != null) { return xids.stream().map(this::getResource).collect(Collectors.toList()); } return Collections.emptyList(); }
3.26
hmily_XaResourcePool_removeAll_rdh
/** * Remove all. * * @param globalId * the global id */ public void removeAll(final String globalId) { Set<Xid> xids = this.xids.get(globalId); if (xids != null) { for (final Xid xid : xids) {removeResource(xid); } this.xids.remove(globalId); } }
3.26
hmily_DefaultValueUtils_getDefaultValue_rdh
/** * Gets default value. * * @param clazz * the clazz * @return the default value * @throws IllegalAccessException * the illegal access exception * @throws InvocationTargetException * the invocation target exception * @throws InstantiationException * the instantiation exception */ public static Object getDefaultValue(final Class clazz) throws IllegalAccessException, InvocationTargetException, InstantiationException { if (boolean.class.equals(clazz) || Boolean.class.equals(clazz)) { return false; } else if (byte.class.equals(clazz) || Byte.class.equals(clazz)) { return ZERO; } else if (short.class.equals(clazz) || Short.class.equals(clazz)) { return ZERO; } else if (int.class.equals(clazz) || Integer.class.equals(clazz)) { return ZERO; } else if (long.class.equals(clazz) || Long.class.equals(clazz)) { return 0L; } else if (float.class.equals(clazz) || Float.class.equals(clazz)) { return 0.0F; } else if (double.class.equals(clazz) || Double.class.equals(clazz)) { return 0.0; } else if (String.class.equals(clazz)) { return ""; } else if (Void.TYPE.equals(clazz)) { return ""; } final Constructor[] v0 = clazz.getDeclaredConstructors(); Constructor constructor = v0[v0.length - 1]; constructor.setAccessible(true); final Class[] parameClasses = constructor.getParameterTypes(); Object[] args = new Object[parameClasses.length];for (int i = 0; i < parameClasses.length; i++) { Class clazzes = parameClasses[i]; if (clazzes.isPrimitive()) { args[i] = 0; } else { args[i] = null; } } return constructor.newInstance(args); }
3.26
hmily_SwaggerConfig_apiInfo_rdh
/** * Api info api info. * * @return the api info */ private ApiInfo apiInfo() { return new ApiInfoBuilder().title("Swagger API").description("dubbo分布式事务解决方案之Hmily测试体验").license("Apache 2.0").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html").termsOfServiceUrl("").version(VERSION).contact(new Contact("xiaoyu", "", "[email protected]")).build(); }
3.26
hmily_SwaggerConfig_api_rdh
/** * Api docket. * * @return the docket */ @Beanpublic Docket api() { return // .paths(paths()) new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)).build().pathMapping("/").directModelSubstitute(LocalDate.class, String.class).genericModelSubstitutes(ResponseEntity.class).useDefaultResponseMessages(false).globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("Error")).build())); }
3.26
hmily_HmilyTacLocalParticipantExecutor_cancel_rdh
/** * Do cancel. * * @param participant * hmily participant */ public static void cancel(final HmilyParticipant participant) { List<HmilyParticipantUndo> undoList = HmilyParticipantUndoCacheManager.getInstance().get(participant.getParticipantId()); for (HmilyParticipantUndo undo : undoList) { boolean success = UndoHook.INSTANCE.run(undo); if (success) {cleanUndo(undo); } } cleanHmilyParticipant(participant); }
3.26
hmily_HmilyTacLocalParticipantExecutor_confirm_rdh
/** * Do confirm. * * @param participant * hmily participant */ public static void confirm(final HmilyParticipant participant) { List<HmilyParticipantUndo> undoList = HmilyParticipantUndoCacheManager.getInstance().get(participant.getParticipantId()); for (HmilyParticipantUndo undo : undoList) {cleanUndo(undo); } cleanHmilyParticipant(participant); }
3.26
hmily_HmilyTransactionRecoveryService_m0_rdh
/** * Confirm. * * @param hmilyParticipant * the hmily participant * @return the boolean */ public boolean m0(final HmilyParticipant hmilyParticipant) { try { HmilyReflector.executor(HmilyActionEnum.CONFIRMING, ExecutorTypeEnum.LOCAL, hmilyParticipant); removeHmilyParticipant(hmilyParticipant.getParticipantId()); return true; } catch (Exception e) { LOGGER.error("hmily Recovery executor confirm exception param:{} ", hmilyParticipant.toString(), e); return false; } }
3.26
hmily_HmilyTransactionRecoveryService_cancel_rdh
/** * Cancel. * * @param hmilyParticipant * the hmily participant * @return the boolean */ public boolean cancel(final HmilyParticipant hmilyParticipant) { try { HmilyReflector.executor(HmilyActionEnum.CANCELING, ExecutorTypeEnum.LOCAL, hmilyParticipant); removeHmilyParticipant(hmilyParticipant.getParticipantId()); return true; } catch (Exception e) { LOGGER.error("hmily Recovery executor cancel exception param {}", hmilyParticipant.toString(), e); return false; } }
3.26
hmily_HmilySQLUtil_m0_rdh
/** * Get exactly SQL expression. * * <p>remove space for SQL expression</p> * * @param value * SQL expression * @return exactly SQL expression */ public static String m0(final String value) { return Strings.isNullOrEmpty(value) ? value : CharMatcher.anyOf(" ").removeFrom(value); }
3.26
hmily_HmilySQLUtil_m1_rdh
/** * Determine whether SQL is read-only. * * @param sqlStatement * SQL statement * @return true if read-only, otherwise false */ public static boolean m1(final HmilyStatement sqlStatement) { if (sqlStatement instanceof HmilyDMLStatement) { return m1(((HmilyDMLStatement) (sqlStatement))); } throw new UnsupportedOperationException(String.format("Unsupported SQL Type `%s`", sqlStatement.getClass().getSimpleName())); }
3.26
hmily_HmilySQLUtil_getExactlyNumber_rdh
/** * Get exactly number value and type. * * @param value * string to be converted * @param radix * radix * @return exactly number value and type */ public static Number getExactlyNumber(final String value, final int radix) {try { return getBigInteger(value, radix); } catch (final NumberFormatException ex) { return new BigDecimal(value); } }
3.26
hmily_HmilySQLUtil_getExpressionWithoutOutsideParentheses_rdh
/** * Get exactly SQL expression without outside parentheses. * * @param value * SQL expression * @return exactly SQL expression */ public static String getExpressionWithoutOutsideParentheses(final String value) { int v1 = getParenthesesOffset(value); return 0 == v1 ? value : value.substring(v1, value.length() - v1); }
3.26
hmily_HmilySQLUtil_getExactlyValue_rdh
/** * Get exactly value for SQL expression. * * <p>remove special char for SQL expression</p> * * @param value * SQL expression * @return exactly SQL expression */ public static String getExactlyValue(final String value) { return null == value ? null : CharMatcher.anyOf("[]`'\"").removeFrom(value); }
3.26
hmily_SpringCloudHmilyOrderApplication_main_rdh
/** * main. * * @param args * args */ public static void main(final String[] args) { SpringApplication.run(SpringCloudHmilyOrderApplication.class, args); }
3.26
hmily_RpcResource_m0_rdh
/** * Gets xa proxy. * * @return the xa proxy */ public RpcXaProxy m0() { return xaProxy; }
3.26
hmily_SchemaCache_get_rdh
/** * acquire Schema with class. * * @param clazz * Class * @return Schema schema */ public Schema<?> get(final Class<?> clazz) { return get(clazz, cache); }
3.26
hmily_SchemaCache_getInstance_rdh
/** * Gets instance. * * @return the instance */protected static SchemaCache getInstance() { return SchemaCacheHolder.cache; }
3.26
hmily_CuratorZookeeperExceptionHandler_handleException_rdh
/** * Handle exception. * * <p>Ignore interrupt and connection invalid exception.</p> * * @param cause * to be handled exception */ public static void handleException(final Exception cause) { if (null == cause) { return; } if (isIgnoredException(cause) || ((null != cause.getCause()) && isIgnoredException(cause.getCause()))) { log.debug("Ignored exception for: {}", cause.getMessage()); } else if (cause instanceof InterruptedException) { Thread.currentThread().interrupt(); } else { throw new ConfigException(cause); } }
3.26
hmily_IndexedBinder_bindIndexed_rdh
/** * Bind indexed elements to the supplied collection. * * @param root * The name of the property to bind * @param target * the target bindable * @param elementBinder * the binder to use for elements * @param aggregateType * the aggregate type, may be a collection or an array * @param elementType * the element type * @param collection * the destination for results */ void bindIndexed(final PropertyName root, final BindData<?> target, final AggregateElementBinder elementBinder, final DataType aggregateType, final DataType elementType, final IndexedCollectionSupplier collection) { ConfigPropertySource source = getEnv().getSource();ConfigProperty property = source.findProperty(root); if (property != null) { m0(collection.get(), property.getValue()); } else { bindIndexed(source, root, elementBinder, collection, elementType); } }
3.26
hmily_ConsulPassiveConfig_fileName_rdh
/** * File name string. * * @return the string */ public String fileName() { return (f0 + ".") + fileExtension; }
3.26
hmily_DatabaseMetaDataDialectHandler_formatTableNamePattern_rdh
/** * Format table name pattern. * * @param tableNamePattern * table name pattern * @return formatted table name pattern */ default String formatTableNamePattern(final String tableNamePattern) { return tableNamePattern;}
3.26
hmily_DatabaseMetaDataDialectHandler_getSchema_rdh
/** * Database meta data dialect handler. */public interface DatabaseMetaDataDialectHandler { /** * Get schema. * * @param connection * connection * @return schema */ default String getSchema(final Connection connection) { try { return connection.getSchema(); } catch (final SQLException ignored) { return null; } }
3.26
hmily_HmilyTimer_addRemovalListener_rdh
/** * 增加一个缓存移除的监听器. * * @param listener * 监听器; */ public void addRemovalListener(final TimerRemovalListener<V> listener) { this.timerRemovalListener = listener; }
3.26
hmily_HmilyTimer_getTime_rdh
/** * get time. * * @return long. time */ public Long getTime() { return time; }
3.26
hmily_HmilyTimer_getValue_rdh
/** * get cache value. * * @return v. value */ public V getValue() { return value; }
3.26
hmily_HmilyTimer_put_rdh
/** * 接收缓存变化值 ,灵活指定过期时间. * * @param v * value * @param expire * 过期时间; * @param unit * 单位; * @return Timeout timeout */ public Timeout put(final V v, final long expire, final TimeUnit unit) { Node node = new Node(v, expire, unit); return timer.newTimeout(node, expire, unit); }
3.26
hmily_CollectionUtils_create_rdh
/** * Create collection. * * @param <E> * the type parameter * @param collectionType * the collection type * @param elementType * the element type * @param capacity * the capacity * @return the collection */ @SuppressWarnings("unchecked") public <E> Collection<E> create(final Class<?> collectionType, final Class<?> elementType, final int capacity) { if (collectionType.isInterface()) { if ((Set.class == collectionType) || (Collection.class == collectionType)) { return new LinkedHashSet<>(capacity); } else if (List.class == collectionType) { return new ArrayList<>(capacity); } else if ((SortedSet.class == collectionType) || (NavigableSet.class == collectionType)) { return new TreeSet<>(); } else { throw new IllegalArgumentException("Unsupported Collection interface: " + collectionType.getName()); } } else if (EnumSet.class == collectionType) { // Cast is necessary for compilation in Eclipse 4.4.1. return ((Collection<E>) (EnumSet.noneOf(asEnumType(elementType)))); } else { if (!Collection.class.isAssignableFrom(collectionType)) { throw new IllegalArgumentException("Unsupported Collection type: " + collectionType.getName()); } try { return ((Collection<E>) (collectionType.newInstance())); } catch (Throwable ex) { throw new IllegalArgumentException("Could not instantiate Collection type: " + collectionType.getName(), ex); } } }
3.26
hmily_CollectionUtils_isNotEmpty_rdh
/** * Is not empty boolean. * * @param coll * the coll * @return the boolean */ public static boolean isNotEmpty(final Collection<?> coll) { return !isEmpty(coll); }
3.26
hmily_CollectionUtils_isEmpty_rdh
/** * Is empty boolean. * * @param coll * the coll * @return the boolean */ public static boolean isEmpty(final Collection<?> coll) { return (coll == null) || coll.isEmpty(); }
3.26
hmily_CollectionUtils_createMap_rdh
/** * Create map map. * * @param <K> * the type parameter * @param <V> * the type parameter * @param mapType * the map type * @param keyType * the key type * @param size * the size * @return the map */ @SuppressWarnings({ "unchecked", "rawtypes" }) <K, V> Map<K, V> createMap(final Class<?> mapType, final Class<?> keyType, final int size) { if (mapType.isInterface()) { if (Map.class == mapType) { return new LinkedHashMap<>(size); } else if ((SortedMap.class == mapType) || (NavigableMap.class == mapType)) { return new TreeMap<>(); } else { throw new IllegalArgumentException("Unsupported Map interface: " + mapType.getName()); } } else if (EnumMap.class == mapType) { return new EnumMap(asEnumType(keyType)); } else { if (!Map.class.isAssignableFrom(mapType)) { throw new IllegalArgumentException("Unsupported Map type: " + mapType.getName()); } try { return ((Map<K, V>) (mapType.newInstance())); } catch (Throwable ex) { throw new IllegalArgumentException("Could not instantiate Map type: " + mapType.getName(), ex); } } }
3.26
hmily_CollectionUtils_asEnumType_rdh
/** * Cast the given type to a subtype of {@link Enum}. * * @param enumType * the enum type, never {@code null} * @return the given type as subtype of {@link Enum} * @throws IllegalArgumentException * if the given type is not a subtype of {@link Enum} */ @SuppressWarnings("rawtypes") private Class<? extends Enum> asEnumType(final Class<?> enumType) { if (!Enum.class.isAssignableFrom(enumType)) { throw new IllegalArgumentException("Supplied type is not an enum: " + enumType.getName());} return enumType.asSubclass(Enum.class); }
3.26
hmily_HmilyConsistentHashDubboLoadBalance_doSelect_rdh
/** * The type ConsistenHash Dubbo hmily load balance. * * @author xiaoyu(Myth) */ public class HmilyConsistentHashDubboLoadBalance extends ConsistentHashLoadBalance { @Override protected <T> Invoker<T> doSelect(final List<Invoker<T>> invokers, final URL url, final Invocation invocation) { Invoker<T> defaultInvoker = super.doSelect(invokers, url, invocation); return HmilyLoadBalanceUtils.doSelect(defaultInvoker, invokers); }
3.26
hmily_DelegationThreadPoolExecutor_onInitialRejection_rdh
/** * On initial rejection. * * @param runnable * the runnable */ private void onInitialRejection(final Runnable runnable) { LOGGER.info("DelegationThreadPoolExecutor:thread {} rejection", runnable);}
3.26
hmily_MetricsReporter_gaugeDecrement_rdh
/** * Gauge decrement. * * @param name * name */public static void gaugeDecrement(final String name) { gaugeDecrement(name, null); }
3.26
hmily_MetricsReporter_registerCounter_rdh
/** * Register counter. * * @param name * name * @param document * document for counter */ public static void registerCounter(final String name, final String document) {registerCounter(name, null, document); }
3.26
hmily_MetricsReporter_gaugeIncrement_rdh
/** * Gauge increment. * * @param name * name */ public static void gaugeIncrement(final String name) { gaugeIncrement(name, null); }
3.26
hmily_MetricsReporter_m0_rdh
/** * Register gauge. * * @param name * name * @param labelNames * label names * @param document * document for gauge */ public static void m0(final String name, final String[] labelNames, final String document) {Optional.ofNullable(metricsRegister).ifPresent(register -> register.registerGauge(name, labelNames, document)); }
3.26
hmily_MetricsReporter_counterIncrement_rdh
/** * Counter increment. * * @param name * name */ public static void counterIncrement(final String name) { counterIncrement(name, null, 1); }
3.26
hmily_MetricsReporter_recordTime_rdh
/** * Record time by duration. * * @param name * name * @param labelValues * label values * @param duration * duration */ public static void recordTime(final String name, final String[] labelValues, final long duration) { Optional.ofNullable(metricsRegister).ifPresent(register -> register.recordTime(name, labelValues, duration)); }
3.26
hmily_MetricsReporter_m1_rdh
/** * Record time by duration. * * @param name * name * @param duration * duration */ public static void m1(final String name, final long duration) { recordTime(name, null, duration); }
3.26
hmily_MetricsReporter_registerMetrics_rdh
/** * Register metrics. * * @param metrics * metric collection */ public static void registerMetrics(final Collection<Metric> metrics) { for (Metric metric : metrics) { switch (metric.getType()) { case COUNTER : registerCounter(metric.getName(), getLabelNames(metric.getLabels()), metric.getDocument()); break; case GAUGE :m0(metric.getName(), getLabelNames(metric.getLabels()), metric.getDocument()); break; case HISTOGRAM : registerHistogram(metric.getName(), getLabelNames(metric.getLabels()), metric.getDocument()); break; default : throw new RuntimeException("we not support metric registration for type: " + metric.getType()); } } }
3.26
hmily_MetricsReporter_register_rdh
/** * Register. * * @param metricsRegister * metrics register */ public static void register(final MetricsRegister metricsRegister) { MetricsReporter.metricsRegister = metricsRegister; }
3.26
hmily_MetricsReporter_registerHistogram_rdh
/** * Register histogram. * * @param name * name * @param document * document for histogram */ public static void registerHistogram(final String name, final String document) {registerHistogram(name, null, document); }
3.26
hmily_MetricsReporter_registerGauge_rdh
/** * Register gauge. * * @param name * name * @param document * document for gauge */ public static void registerGauge(final String name, final String document) { m0(name, null, document); }
3.26
hmily_HmilyUndoContext_getHmilyLocks_rdh
/** * Get hmily locks. * * @return hmily locks */ public Collection<HmilyLock> getHmilyLocks() { return dataSnapshot.getTuples().stream().map(tuple -> new HmilyLock(transId, participantId, resourceId, tuple.getTableName(), Joiner.on("_").join(tuple.getPrimaryKeyValues()))).collect(Collectors.toList()); }
3.26
hmily_TableMetaDataLoader_load_rdh
/** * Load table meta data. * * @param connectionAdapter * connection adapter * @param tableNamePattern * table name pattern * @param databaseType * database type * @return table meta data * @throws SQLException * SQL exception */ public static Optional<TableMetaData> load(final MetaDataConnectionAdapter connectionAdapter, final String tableNamePattern, final DatabaseType databaseType) throws SQLException { String v0 = formatTableNamePattern(tableNamePattern, databaseType); return isTableExist(connectionAdapter, v0) ? Optional.of(new TableMetaData(v0, ColumnMetaDataLoader.load(connectionAdapter, v0, databaseType), IndexMetaDataLoader.load(connectionAdapter, v0))) : Optional.empty(); }
3.26
hmily_HmilyTacParticipantCoordinator_rollbackParticipant_rdh
/** * Rollback participant. * * @param hmilyParticipantList * the hmily participant list * @param selfParticipantId * the self participant id */ public void rollbackParticipant(final List<HmilyParticipant> hmilyParticipantList, final Long selfParticipantId) { if (CollectionUtils.isEmpty(hmilyParticipantList)) { return; } log.debug("TAC-participate-rollback ::: {}", hmilyParticipantList); for (HmilyParticipant participant : hmilyParticipantList) { try { if (participant.getParticipantId().equals(selfParticipantId)) { HmilyTacLocalParticipantExecutor.cancel(participant); } else { HmilyReflector.executor(HmilyActionEnum.CANCELING, ExecutorTypeEnum.RPC, participant); }} catch (Throwable e) { log.error("HmilyParticipant rollback exception :{} ", participant.toString()); throw new HmilyRuntimeException(" hmilyParticipant execute rollback exception:" + participant.toString()); } finally {// FIXME why remove context after first participator handled HmilyContextHolder.remove(); } } }
3.26
hmily_HmilyTacParticipantCoordinator_beginParticipant_rdh
/** * Begin hmily transaction. * * @param context * the context * @param point * the point * @return the hmily transaction */ public HmilyParticipant beginParticipant(final HmilyTransactionContext context, final ProceedingJoinPoint point) { // 创建全局的事务,创建一个参与者 final HmilyParticipant hmilyParticipant = buildHmilyParticipant(point, context.getParticipantId(), context.getParticipantRefId(), context.getTransId()); HmilyParticipantCacheManager.getInstance().cacheHmilyParticipant(hmilyParticipant); HmilyRepositoryStorage.createHmilyParticipant(hmilyParticipant); context.setRole(HmilyRoleEnum.PARTICIPANT.getCode());HmilyContextHolder.set(context); log.debug("TAC-participate-join ::: {}", hmilyParticipant); return hmilyParticipant; }
3.26
hmily_HmilyTacParticipantCoordinator_commitParticipant_rdh
/** * Commit participant. * * @param hmilyParticipantList * the hmily participant list * @param selfParticipantId * the self participant id */ public void commitParticipant(final List<HmilyParticipant> hmilyParticipantList, final Long selfParticipantId) { if (CollectionUtils.isEmpty(hmilyParticipantList)) { return; } log.debug("TAC-participate-commit ::: {}", hmilyParticipantList); for (HmilyParticipant participant : hmilyParticipantList) { try { if (participant.getParticipantId().equals(selfParticipantId)) { HmilyTacLocalParticipantExecutor.confirm(participant); } else { HmilyReflector.executor(HmilyActionEnum.CONFIRMING, ExecutorTypeEnum.RPC, participant); }} catch (Throwable throwable) { throw new HmilyRuntimeException(" hmilyParticipant execute confirm exception:" + participant.toString());} finally { // FIXME why remove context after first participator handled HmilyContextHolder.remove(); } } }
3.26
hmily_HmilyTacParticipantCoordinator_buildHmilyParticipant_rdh
// TODO need review it with rpc.build-participant private HmilyParticipant buildHmilyParticipant(final ProceedingJoinPoint point, final Long participantId, final Long participantRefId, final Long transId) {HmilyParticipant hmilyParticipant = new HmilyParticipant(); if (null == participantId) { hmilyParticipant.setParticipantId(IdWorkerUtils.getInstance().createUUID()); } else { hmilyParticipant.setParticipantId(participantId); } if (null != participantRefId) { hmilyParticipant.setParticipantRefId(participantRefId); MethodSignature signature = ((MethodSignature) (point.getSignature())); Method method = signature.getMethod(); Class<?> clazz = point.getTarget().getClass(); Object[] args = point.getArgs(); HmilyInvocation v8 = new HmilyInvocation(clazz.getInterfaces()[0], method.getName(), method.getParameterTypes(), args); hmilyParticipant.setConfirmHmilyInvocation(v8); } hmilyParticipant.setTransId(transId); hmilyParticipant.setTransType(TransTypeEnum.TAC.name()); hmilyParticipant.setStatus(HmilyActionEnum.PRE_TRY.getCode()); hmilyParticipant.setRole(HmilyRoleEnum.PARTICIPANT.getCode()); return hmilyParticipant; }
3.26
hmily_NacosClient_pull_rdh
/** * Pull input stream. * * @param config * the config * @return the input stream */InputStream pull(final NacosConfig config) { Properties properties = new Properties(); properties.put(NACOS_SERVER_ADDR_KEY, config.getServer()); try { configService = NacosFactory.createConfigService(properties); String content = configService.getConfig(config.getDataId(), config.getGroup(), config.getTimeoutMs()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("nacos content {}", content); } if (StringUtils.isBlank(content)) { return null; } return new ByteArrayInputStream(content.getBytes()); } catch (NacosException e) { throw new ConfigException(e); } }
3.26
hmily_NacosClient_addListener_rdh
/** * Add listener. * * @param context * the context * @param passiveHandler * the passive handler * @param config * the config * @throws NacosException * the nacos exception */ void addListener(final Supplier<ConfigLoader.Context> context, final ConfigLoader.PassiveHandler<NacosPassiveConfig> passiveHandler, final NacosConfig config) throws NacosException { if (!config.isPassive()) { return; } if (configService == null) { LOGGER.warn("nacos configService is null..."); } configService.addListener(config.getDataId(), config.getGroup(), new Listener() { @Override public Executor getExecutor() { return null;} @Override public void receiveConfigInfo(final String s) { NacosPassiveConfig nacosPassiveConfig = new NacosPassiveConfig(); nacosPassiveConfig.setValue(s); nacosPassiveConfig.setFileExtension(config.getFileExtension()); nacosPassiveConfig.setDataId(config.getDataId()); passiveHandler.passive(context, nacosPassiveConfig); } }); LOGGER.info("passive nacos remote started...."); }
3.26
hmily_Timeout_isDefault_rdh
/** * 是否为自定义的一个timeout. * * @return true or false. */ default boolean isDefault() { return true; }
3.26
hmily_DubboHmilyOrderApplication_main_rdh
/** * main. * * @param args * args */ public static void main(final String[] args) { SpringApplication.run(DubboHmilyOrderApplication.class, args); }
3.26
hmily_HmilyApplicationContextAware_postProcessBeanFactory_rdh
/** * Fix metric register happen before initialize. */ @Override public void postProcessBeanFactory(@NonNull final ConfigurableListableBeanFactory beanFactory) throws BeansException { HmilyBootstrap.getInstance().start(); }
3.26
hmily_HmilyParen_isLeftParen_rdh
/** * Judge passed token is left paren or not. * * @param token * token * @return is left paren or not */ public static boolean isLeftParen(final char token) { return Arrays.stream(values()).anyMatch(each -> each.leftParen == token); }
3.26
hmily_HmilyParen_match_rdh
/** * Judge left paren match right paren or not. * * @param leftToken * left token * @param rightToken * right token * @return match or not */ public static boolean match(final char leftToken, final char rightToken) { for (HmilyParen each : HmilyParen.values()) { if ((each.leftParen == leftToken) && (each.f0 == rightToken)) { return true; } } return false; }
3.26
hmily_DubboRpcXaProxy_getUrl_rdh
/** * Gets url. * * @return the url */ public String getUrl() { return invoker.getUrl().toString(); }
3.26
hmily_ConsulClient_put_rdh
/** * put config content. * * @param key * config key * @param content * config content */ public void put(final String key, final String content) { f0.keyValueClient().putValue(key, content); }
3.26
hmily_ConsulClient_addListener_rdh
/** * Add listener. * * @param context * the context * @param passiveHandler * the passive handler * @param config * the config * @throws InterruptedException * exception */ void addListener(final Supplier<ConfigLoader.Context> context, final ConfigLoader.PassiveHandler<ConsulPassiveConfig> passiveHandler, final ConsulConfig config) throws InterruptedException { if (!config.isPassive()) { return; } if (f0 == null) { LOGGER.warn("Consul client is null..."); } ConsulCache consulCache = KVCache.newCache(f0.keyValueClient(), config.getKey()); consulCache.addListener(map -> { Set<Map.Entry<Object, Value>> set = map.entrySet(); set.forEach(x -> { ConsulPassiveConfig consulPassiveConfig = new ConsulPassiveConfig(); consulPassiveConfig.setKey(config.getKey()); consulPassiveConfig.setFileExtension(config.getFileExtension()); consulPassiveConfig.setValue(x.getValue().getValueAsString(Charset.forName("utf-8")).get()); passiveHandler.passive(context, consulPassiveConfig); }); }); consulCache.start(); LOGGER.info("passive consul remote started...."); }
3.26
hmily_ConsulClient_buildHostAndPortList_rdh
/** * build hostAndPorts. * * @param hostAndPorts * address * @return HostAndPortList */ private static List<HostAndPort> buildHostAndPortList(final String hostAndPorts) { if (StringUtils.isNoneBlank(hostAndPorts)) { String[] hostAndPortArray = hostAndPorts.split(","); List<HostAndPort> hostAndPortList = new ArrayList<>();for (String hostAndPort : hostAndPortArray) { hostAndPortList.add(HostAndPort.fromString(hostAndPort)); } return hostAndPortList; } return Collections.emptyList(); }
3.26
hmily_ConsulClient_getInstance_rdh
/** * get instance. * * @param consulConfig * consul config * @return consulClient */ public static ConsulClient getInstance(final ConsulConfig consulConfig) { String hostAndPorts = consulConfig.getHostAndPorts(); List<HostAndPort> hostAndPortList = buildHostAndPortList(hostAndPorts); Consul consul; if (StringUtils.isNoneBlank(consulConfig.getHostAndPorts())) { consul = Consul.builder().withMultipleHostAndPort(hostAndPortList, consulConfig.getBlacklistTimeInMillis()).build().newClient(); } else { consul = Consul.builder().withHostAndPort(HostAndPort.fromString(consulConfig.getHostAndPort())).build().newClient(); } ConsulClient consulClient = new ConsulClient(); consulClient.setConsul(consul); return consulClient; }
3.26
hmily_ConsulClient_setConsul_rdh
/** * set consul. * * @param consul * consul client */ public void setConsul(final Consul consul) { this.f0 = consul; }
3.26
hmily_ConsulClient_pull_rdh
/** * pull. * * @param consulConfig * consul config * @return InputStream */ public InputStream pull(final ConsulConfig consulConfig) { if (f0 == null) { if (StringUtils.isNoneBlank(consulConfig.getHostAndPorts())) { f0 = Consul.builder().withMultipleHostAndPort(buildHostAndPortList(consulConfig.getHostAndPorts()), consulConfig.getBlacklistTimeInMillis()).build().newClient();} else { f0 = Consul.builder().withHostAndPort(HostAndPort.fromString(consulConfig.getHostAndPort())).build().newClient(); } } Value value = f0.keyValueClient().getValue(consulConfig.getKey()).orElse(null); if (value == null) { return null; } String content = value.getValueAsString(Charset.forName("utf-8")).get(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("consul content {}", content); } if (StringUtils.isBlank(content)) { return null; } return new ByteArrayInputStream(content.getBytes(Charset.forName("utf-8"))); }
3.26
hmily_HmilyRepositoryStorage_removeHmilyTransaction_rdh
/** * Remove hmily transaction. * * @param hmilyTransaction * the hmily transaction */ public static void removeHmilyTransaction(final HmilyTransaction hmilyTransaction) { if (Objects.nonNull(hmilyTransaction)) { PUBLISHER.asyncPublishEvent(hmilyTransaction, EventTypeEnum.REMOVE_HMILY_TRANSACTION.getCode()); } }
3.26
hmily_HmilyRepositoryStorage_updateHmilyTransactionStatus_rdh
/** * Update hmily transaction status. * * @param hmilyTransaction * the hmily transaction */ public static void updateHmilyTransactionStatus(final HmilyTransaction hmilyTransaction) { if (Objects.nonNull(hmilyTransaction)) { PUBLISHER.publishEvent(hmilyTransaction, EventTypeEnum.UPDATE_HMILY_TRANSACTION_STATUS.getCode()); } }
3.26
hmily_HmilyRepositoryStorage_createHmilyTransaction_rdh
/** * Create hmily transaction. * * @param hmilyTransaction * the hmily transaction */ public static void createHmilyTransaction(final HmilyTransaction hmilyTransaction) { if (Objects.nonNull(hmilyTransaction)) { PUBLISHER.publishEvent(hmilyTransaction, EventTypeEnum.CREATE_HMILY_TRANSACTION.getCode()); } }
3.26
hmily_HmilyRepositoryStorage_m0_rdh
/** * Try to write locks. * * @param hmilyLocks * hmily locks */ public static void m0(final Collection<HmilyLock> hmilyLocks) { if (!hmilyLocks.isEmpty()) { PUBLISHER.syncPublishEvent(hmilyLocks, EventTypeEnum.WRITE_HMILY_LOCKS.getCode()); } }
3.26
hmily_HmilyRepositoryStorage_removeHmilyParticipant_rdh
/** * Remove hmily participant. * * @param hmilyParticipant * the hmily participant */ public static void removeHmilyParticipant(final HmilyParticipant hmilyParticipant) { if (Objects.nonNull(hmilyParticipant)) { PUBLISHER.publishEvent(hmilyParticipant, EventTypeEnum.REMOVE_HMILY_PARTICIPANT.getCode()); } }
3.26
hmily_HmilyRepositoryStorage_releaseHmilyLocks_rdh
/** * Release locks.. * * @param hmilyLocks * hmily locks */public static void releaseHmilyLocks(final Collection<HmilyLock> hmilyLocks) { if (!hmilyLocks.isEmpty()) { PUBLISHER.syncPublishEvent(hmilyLocks, EventTypeEnum.RELEASE_HMILY_LOCKS.getCode()); } }
3.26
hmily_HmilyRepositoryStorage_removeHmilyParticipantUndo_rdh
/** * Remove hmily participant undo. * * @param hmilyParticipantUndo * the hmily participant undo */ public static void removeHmilyParticipantUndo(final HmilyParticipantUndo hmilyParticipantUndo) {if (Objects.nonNull(hmilyParticipantUndo)) { PUBLISHER.publishEvent(hmilyParticipantUndo, EventTypeEnum.REMOVE_HMILY_PARTICIPANT_UNDO.getCode()); } }
3.26
hmily_HmilyRepositoryStorage_createHmilyParticipant_rdh
/** * Create hmily participant. * * @param hmilyParticipant * the hmily participant */ public static void createHmilyParticipant(final HmilyParticipant hmilyParticipant) { if (Objects.nonNull(hmilyParticipant)) { PUBLISHER.publishEvent(hmilyParticipant, EventTypeEnum.CREATE_HMILY_PARTICIPANT.getCode());} }
3.26
hmily_HmilyRepositoryStorage_updateHmilyParticipantStatus_rdh
/** * Update hmily participant status. * * @param hmilyParticipant * the hmily participant */ public static void updateHmilyParticipantStatus(final HmilyParticipant hmilyParticipant) { if (Objects.nonNull(hmilyParticipant)) { PUBLISHER.publishEvent(hmilyParticipant, EventTypeEnum.UPDATE_HMILY_PARTICIPANT_STATUS.getCode()); } }
3.26
hmily_HmilyRepositoryStorage_createHmilyParticipantUndo_rdh
/** * Create hmily participant undo. * * @param hmilyParticipantUndo * the hmily participant undo */ public static void createHmilyParticipantUndo(final HmilyParticipantUndo hmilyParticipantUndo) { if (Objects.nonNull(hmilyParticipantUndo)) { PUBLISHER.publishEvent(hmilyParticipantUndo, EventTypeEnum.CREATE_HMILY_PARTICIPANT_UNDO.getCode()); } }
3.26
hmily_HmilyInsertStatement_getInsertColumns_rdh
/** * Get insert columns segment. * * @return insert columns segment */ public Optional<HmilyInsertColumnsSegment> getInsertColumns() { return Optional.ofNullable(insertColumns); }
3.26
hmily_SingletonHolder_get_rdh
/** * Get t. * * @param <T> * the type parameter * @param clazz * the clazz * @return the t */ @SuppressWarnings("unchecked") public <T> T get(final Class<T> clazz) { return ((T) (SINGLES.get(clazz.getName()))); }
3.26