name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
hmily_HmilyCollectionValue_combine_rdh
/** * Put all values from another collection value into this one. * * @param hmilyCollectionValue * collection value */ public void combine(final HmilyCollectionValue<T> hmilyCollectionValue) { value.addAll(hmilyCollectionValue.value); }
3.26
hmily_SpringCloudXaProxy_getArgs_rdh
/** * Get Feign method arguments. * * @return method arguments */ public Object[] getArgs() { return args; }
3.26
hmily_HmilySqlParserEngineFactory_newInstance_rdh
/** * New instance hmily sql parser engine. * * @return the hmily sql parser engine */ public static HmilySqlParserEngine newInstance() { if (hmilySqlParserEngine == null) { synchronized(HmilySqlParserEngineFactory.class) { if (hmilySqlParserEngine == null) { HmilyConfig config = ConfigEnv.getInstance().getConfig(HmilyConfig.class); hmilySqlParserEngine = ExtensionLoaderFactory.load(HmilySqlParserEngine.class, config.getSqlParserType()); } } } return hmilySqlParserEngine; }
3.26
hmily_HmilyQuoteCharacter_getQuoteCharacter_rdh
/** * Get quote character. * * @param value * value to be get quote character * @return value of quote character */ public static HmilyQuoteCharacter getQuoteCharacter(final String value) { if (Strings.isNullOrEmpty(value)) { return NONE; } return Arrays.stream(values()).filter(each -> (NONE != each) && (each.startDelimiter.charAt(0) == value.charAt(0))).findFirst().orElse(NONE); }
3.26
hmily_HmilyQuoteCharacter_wrap_rdh
/** * Wrap value with quote character. * * @param value * value to be wrapped * @return wrapped value */ public String wrap(final String value) { return String.format("%s%s%s", startDelimiter, value, endDelimiter); }
3.26
hmily_EtcdClient_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<EtcdPassiveConfig> passiveHandler, final EtcdConfig config) throws InterruptedException { if (!config.isPassive()) { return; } if (client == null) { LOGGER.warn("Etcd client is null..."); } new Thread(() -> { while (true) { try { client.getWatchClient().watch(ByteSequence.fromString(config.getKey())).listen().getEvents().stream().forEach(watchEvent -> { KeyValue keyValue = watchEvent.getKeyValue(); EtcdPassiveConfig etcdPassiveConfig = new EtcdPassiveConfig(); etcdPassiveConfig.setKey(config.getKey()); etcdPassiveConfig.setFileExtension(config.getFileExtension()); etcdPassiveConfig.setValue(keyValue.getValue() != null ? keyValue.getValue().toStringUtf8() : null); passiveHandler.passive(context, etcdPassiveConfig); }); } catch (InterruptedException e) { LOGGER.error("", e); } } }).start(); LOGGER.info("passive Etcd remote started...."); }
3.26
hmily_EtcdClient_pull_rdh
/** * Pull input stream. * * @param config * the config * @return the input stream */ public InputStream pull(final EtcdConfig config) { if (client == null) { client = Client.builder().endpoints(config.getServer()).build(); } try { CompletableFuture<GetResponse> future = client.getKVClient().get(ByteSequence.fromString(config.getKey())); List<KeyValue> kvs; if (config.getTimeoutMs() > 0L) { kvs = future.get(config.getTimeoutMs(), TimeUnit.MILLISECONDS).getKvs(); } else { kvs = future.get().getKvs(); } if (CollectionUtils.isNotEmpty(kvs)) { String content = kvs.get(0).getValue().toStringUtf8(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("etcd content {}", content); } if (StringUtils.isBlank(content)) { return null; }return new ByteArrayInputStream(content.getBytes()); } return null; } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new ConfigException(e); } }
3.26
hmily_EtcdClient_getInstance_rdh
/** * get instance of EtcdClient. * * @param config * etcdConfig * @return etcd Client */ public static EtcdClient getInstance(final EtcdConfig config) { Client client = Client.builder().endpoints(config.getServer()).build(); EtcdClient etcdClient = new EtcdClient(); etcdClient.setClient(client); return etcdClient; }
3.26
hmily_EtcdClient_put_rdh
/** * put config content. * * @param key * config key * @param content * config content */ public void put(final String key, final String content) { try { client.getKVClient().put(ByteSequence.fromString(key), ByteSequence.fromString(content)).get(); } catch (InterruptedException | ExecutionException e) { throw new ConfigException(e); } }
3.26
hmily_EtcdClient_setClient_rdh
/** * set client. * * @param client * client */ public void setClient(final Client client) { this.client = client; }
3.26
hmily_HmilySQLServerInsertStatement_getOutputSegment_rdh
/** * Get output segment. * * @return output segment. */ public Optional<HmilyOutputSegment> getOutputSegment() { return Optional.ofNullable(outputSegment); }
3.26
hmily_TransactionManagerImpl_markTransactionRollback_rdh
/** * 把事务标记为回滚状态. * * @param transId * 事务id. */ public void markTransactionRollback(final String transId) { hmilyXaTransactionManager.markTransactionRollback(transId); }
3.26
hmily_TransactionManagerImpl_isExistDataSources_rdh
/** * Is exist data sources boolean. * * @param connection * the connection * @return the boolean */ public boolean isExistDataSources(final XAConnection connection) { boolean contains = enlisted.get().contains(connection); Transaction transaction = getTransaction(); if (!contains) { try { transaction.registerSynchronization(new Synchronization() { @Override public void beforeCompletion() { enlisted.get().remove(connection); } @Override public void afterCompletion(final int status) { enlisted.get().clear(); enlisted.remove(); } }); } catch (RollbackException | SystemException e) { return false; } enlisted.get().add(connection); }return contains; }
3.26
hmily_VersionUtils_getVersion_rdh
/** * Gets version. * * @param cls * the cls * @param defaultVersion * the default version * @return the version */ public static String getVersion(final Class<?> cls, final String defaultVersion) { try { // find version info from MANIFEST.MF first String version = cls.getPackage().getImplementationVersion(); if ((version == null) || (version.length() == 0)) { version = cls.getPackage().getSpecificationVersion(); } if ((version == null) || (version.length() == 0)) { // guess version fro jar file name if nothing's found from MANIFEST.MF CodeSource codeSource = cls.getProtectionDomain().getCodeSource(); if (codeSource == null) { LOGGER.info((("No codeSource for class " + cls.getName()) + " when getVersion, use default version ") + defaultVersion); } else {String file = codeSource.getLocation().getFile(); if (((file != null) && (file.length() > 0)) && file.endsWith(".jar")) { file = file.substring(0, file.length() - 4); int i = file.lastIndexOf('/'); if (i >= 0) { file = file.substring(i + 1); } i = file.indexOf("-"); if (i >= 0) { file = file.substring(i + 1); } while ((file.length() > 0) && (!Character.isDigit(file.charAt(0)))) { i = file.indexOf("-"); if (i >= 0) { file = file.substring(i + 1); } else { break; } } version = file; } } } // return default version if no version info is found return (version == null) || (version.length() == 0) ? defaultVersion : version; } catch (Exception e) { // return default version when any exception is thrown LOGGER.error("return default version, ignore exception " + e.getMessage(), e); return defaultVersion; } }
3.26
hmily_HmilyConsistentHashLoadBalance_select_rdh
/** * Use load balancing to select invoker. * * @param invocation * invocation * @return Invoker * @throws NoInvokerException * NoInvokerException */ @Override public Invoker<T> select(final InvokeContext invocation) throws NoInvokerException { long consistentHash = Math.abs(StringUtils.convertLong(invocation.getAttachment(Constants.TARS_CONSISTENT_HASH), 0)); consistentHash = consistentHash & 0xffffffffL; ConcurrentSkipListMap<Long, Invoker<T>> conHashInvokers = conHashInvokersCache; if ((conHashInvokers != null) && (!conHashInvokers.isEmpty())) { if (!conHashInvokers.containsKey(consistentHash)) { SortedMap<Long, Invoker<T>> tailMap = conHashInvokers.tailMap(consistentHash); if (tailMap.isEmpty()) { consistentHash = conHashInvokers.firstKey(); } else { consistentHash = tailMap.firstKey(); } } Invoker<T> invoker = conHashInvokers.get(consistentHash); if (invoker.isAvailable()) { return invoker; } ServantInvokerAliveStat stat = ServantInvokerAliveChecker.get(invoker.getUrl()); if (stat.isAlive() || ((stat.getLastRetryTime() + (config.getTryTimeInterval() * 1000)) < System.currentTimeMillis())) { LOGGER.info("try to use inactive invoker|" + invoker.getUrl().toIdentityString()); stat.setLastRetryTime(System.currentTimeMillis()); return invoker; } } if (LOGGER.isDebugEnabled()) { LOGGER.debug(config.getSimpleObjectName() + " can't find active invoker using consistent hash loadbalance. try to use normal hash"); } List<Invoker<T>> sortedInvokers = sortedInvokersCache;if ((sortedInvokers == null) || sortedInvokers.isEmpty()) { throw new NoInvokerException("no such active connection invoker"); } List<Invoker<T>> list = new ArrayList<Invoker<T>>(); for (Invoker<T> invoker : sortedInvokers) { if (!invoker.isAvailable()) { // Shield then call ServantInvokerAliveStat stat = ServantInvokerAliveChecker.get(invoker.getUrl()); if (stat.isAlive() || ((stat.getLastRetryTime() + (config.getTryTimeInterval() * 1000)) < System.currentTimeMillis())) { list.add(invoker); } } else { list.add(invoker); } } // TODO When all is not available. Whether to randomly extract one if (list.isEmpty()) { throw new NoInvokerException(((config.getSimpleObjectName() + " try to select active invoker, size=") + sortedInvokers.size()) + ", no such active connection invoker"); } Invoker<T> invoker = list.get(((int) (consistentHash % list.size()))); if (!invoker.isAvailable()) { LOGGER.info("try to use inactive invoker|" + invoker.getUrl().toIdentityString()); ServantInvokerAliveChecker.get(invoker.getUrl()).setLastRetryTime(System.currentTimeMillis()); } return HmilyLoadBalanceUtils.doSelect(invoker, sortedInvokersCache); }
3.26
hmily_HmilyConsistentHashLoadBalance_refresh_rdh
/** * Refresh local invoker. * * @param invokers * invokers */ @Overridepublic void refresh(final Collection<Invoker<T>> invokers) { LOGGER.info((config.getSimpleObjectName() + " try to refresh ConsistentHashLoadBalance's invoker cache, size=") + ((invokers == null) || invokers.isEmpty() ? 0 : invokers.size())); if (CollectionUtils.isEmpty(invokers)) { sortedInvokersCache = null; conHashInvokersCache = null; return; } List<Invoker<T>> sortedInvokersTmp = new ArrayList<>(invokers); sortedInvokersTmp.sort(comparator);sortedInvokersCache = sortedInvokersTmp; ConcurrentSkipListMap<Long, Invoker<T>> concurrentSkipListMap = new ConcurrentSkipListMap<Long, Invoker<T>>(); LoadBalanceHelper.buildConsistentHashCircle(sortedInvokersTmp, config).forEach(concurrentSkipListMap::put); conHashInvokersCache = concurrentSkipListMap; LOGGER.info((((config.getSimpleObjectName() + " refresh ConsistentHashLoadBalance's invoker cache done, conHashInvokersCache size=") + ((conHashInvokersCache == null) || conHashInvokersCache.isEmpty() ? 0 : conHashInvokersCache.size())) + ", sortedInvokersCache size=") + ((sortedInvokersCache == null) || sortedInvokersCache.isEmpty() ? 0 : sortedInvokersCache.size())); }
3.26
hmily_ServerConfigLoader_getDirGlobal_rdh
/** * Get the current project path. * * @return Current project path */ private String getDirGlobal() { String userDir = System.getProperty("user.dir"); String fileName = "hmily.yml"; return String.join(String.valueOf(File.separatorChar), userDir, fileName); }
3.26
hmily_HmilyDisruptor_startup_rdh
/** * start disruptor. */ @SuppressWarnings("unchecked")public void startup() { Disruptor<DataEvent<T>> disruptor = new Disruptor<>(new DisruptorEventFactory<>(), size, HmilyThreadFactory.create("disruptor_consumer_" + consumer.fixName(), false), ProducerType.MULTI, new BlockingWaitStrategy()); HmilyDisruptorWorkHandler<T>[] workerPool = new HmilyDisruptorWorkHandler[consumerSize];for (int i = 0; i < consumerSize; i++) { workerPool[i] = new HmilyDisruptorWorkHandler<>(consumer); } disruptor.handleEventsWithWorkerPool(workerPool); disruptor.setDefaultExceptionHandler(new IgnoreExceptionHandler()); disruptor.start(); RingBuffer<DataEvent<T>> ringBuffer = disruptor.getRingBuffer(); provider = new DisruptorProvider<>(ringBuffer, disruptor); }
3.26
hmily_ConfigProperty_of_rdh
/** * Of config property. * * @param name * the name * @param value * the value * @return the config property */ public static ConfigProperty of(final PropertyName name, final Object value) { return Optional.ofNullable(value).map(cf -> new ConfigProperty(name, cf)).orElse(null); }
3.26
hmily_HmilyLimitSegment_getOffset_rdh
/** * Get offset. * * @return offset */ public Optional<HmilyPaginationValueSegment> getOffset() { return Optional.ofNullable(offset); }
3.26
hmily_ConfigEnv_addEvent_rdh
/** * Add an event subscription processing. * * @param <T> * the type parameter * @param consumer * the consumer */ @SuppressWarnings({ "unchecked", "rawtypes" }) public synchronized <T extends EventData> void addEvent(final EventConsumer<T> consumer) { EVENTS.add(((EventConsumer) (consumer))); }
3.26
hmily_ConfigEnv_registerConfig_rdh
/** * Register config. * * @param config * the config */ public void registerConfig(final Config config) { if (config.getClass().getSuperclass().isAssignableFrom(AbstractConfig.class)) { putBean(config); } }
3.26
hmily_ConfigEnv_getConfig_rdh
/** * Gets config. * * @param <T> * the type parameter * @param clazz * the clazz * @return the config */ @SuppressWarnings("unchecked") public <T extends Config> T getConfig(final Class<T> clazz) { return ((T) (CONFIGS.get(clazz)));}
3.26
hmily_ConfigEnv_putBean_rdh
/** * Register an object that needs to interpret configuration information . * * @param parent * parent. */ public void putBean(final Config parent) { if ((parent != null) && StringUtils.isNotBlank(parent.prefix())) {if (CONFIGS.containsKey(parent.getClass())) { return; } CONFIGS.put(parent.getClass(), parent); } }
3.26
hmily_OriginTrackedYamlLoader_load_rdh
/** * Load list. * * @return the list */ public List<Map<String, Object>> load() { final List<Map<String, Object>> result = new ArrayList<>(); process((properties, map) -> result.add(getFlattenedMap(map))); return result; }
3.26
hmily_OriginTrackedYamlLoader_get_rdh
/** * Get node tuple. * * @param nodeTuple * the node tuple * @return the node tuple */ public static NodeTuple get(final NodeTuple nodeTuple) { Node keyNode = nodeTuple.getKeyNode(); Node valueNode = nodeTuple.getValueNode(); return new NodeTuple(KeyScalarNode.get(keyNode), valueNode); }
3.26
hmily_ConfigScan_scan_rdh
/** * Scan all config to add config env. */ public static void scan() { List<Config> configs = ExtensionLoaderFactory.loadAll(Config.class); for (Config conf : configs) {ConfigEnv.getInstance().registerConfig(conf); } }
3.26
hmily_MongodbXaRepository_convert_rdh
/** * Convert hmily xa recovery. * * @param entity * the entity * @return the hmily xa recovery */ private HmilyXaRecovery convert(final XaRecoveryMongoEntity entity) { return HmilyXaRecoveryImpl.convert(entity); }
3.26
hmily_HmilyThreadFactory_create_rdh
/** * create custom thread factory. * * @param namePrefix * prefix * @param daemon * daemon * @return {@linkplain ThreadFactory} */ public static ThreadFactory create(final String namePrefix, final boolean daemon) { return new HmilyThreadFactory(namePrefix, daemon); }
3.26
hmily_ResourceIdUtils_getResourceId_rdh
/** * Gets resource id. * * @param jdbcUrl * the jdbc url * @return the resource id */ public String getResourceId(final String jdbcUrl) { return resourceIds.computeIfAbsent(jdbcUrl, u -> u.contains("?") ? u.substring(0, u.indexOf('?')) : u); }
3.26
hmily_InventoryServiceImpl_confirmMethod_rdh
/** * Confirm method boolean. * * @param inventoryDTO * the inventory dto * @return the boolean */ public Boolean confirmMethod(InventoryDTO inventoryDTO) { LOGGER.info("==========调用扣减库存confirm方法==========="); inventoryMapper.confirm(inventoryDTO); final int i = confirmCount.incrementAndGet(); LOGGER.info(("调用了inventory confirm " + i) + " 次"); return true; }
3.26
hmily_InventoryServiceImpl_cancelMethod_rdh
/** * Cancel method boolean. * * @param inventoryDTO * the inventory dto * @return the boolean */ public Boolean cancelMethod(InventoryDTO inventoryDTO) { LOGGER.info("==========调用扣减库存取消方法==========="); inventoryMapper.cancel(inventoryDTO); return true; }
3.26
hmily_HmilyLogicalOperator_valueFrom_rdh
/** * Get logical operator value from text. * * @param text * text * @return logical operator value */ public static Optional<HmilyLogicalOperator> valueFrom(final String text) { return Arrays.stream(values()).filter(each -> each.texts.contains(text)).findFirst(); }
3.26
hmily_Coordinator_addCoordinators_rdh
/** * Add coordinators boolean. * * @param resource * the remote * @return the boolean */ public synchronized boolean addCoordinators(final Resource resource) {if (coordinators.contains(resource)) { return true; } boolean add = this.coordinators.add(resource); if (add) { hmilyTimer.put(resource); } return add; }
3.26
hmily_Coordinator_setRollbackOnly_rdh
/** * Sets rollback only. */ public void setRollbackOnly() { if (state == XaState.STATUS_ACTIVE) { state = XaState.STATUS_MARKED_ROLLBACK; } }
3.26
hmily_Coordinator_getState_rdh
/** * Gets state. * * @return the state */ public XaState getState() { return state; }
3.26
hmily_HmilyRepositoryEventPublisher_syncPublishEvent_rdh
/** * Sync publish event. * * @param hmilyLocks * the hmily locks * @param type * type */ public void syncPublishEvent(final Collection<HmilyLock> hmilyLocks, final int type) { HmilyRepositoryEvent event = new HmilyRepositoryEvent(); event.setType(type); event.setTransId(hmilyLocks.iterator().next().getTransId()); event.setHmilyLocks(hmilyLocks); HmilyRepositoryEventDispatcher.getInstance().doDispatch(event); }
3.26
hmily_HmilyRepositoryEventPublisher_getInstance_rdh
/** * Gets instance. * * @return the instance */public static HmilyRepositoryEventPublisher getInstance() { return INSTANCE; }
3.26
hmily_HmilyRepositoryEventPublisher_publishEvent_rdh
/** * Publish event. * * @param hmilyParticipant * the hmily participant * @param type * the type */ public void publishEvent(final HmilyParticipant hmilyParticipant, final int type) { HmilyRepositoryEvent v5 = new HmilyRepositoryEvent(); v5.setType(type); v5.setTransId(hmilyParticipant.getTransId()); v5.setHmilyParticipant(hmilyParticipant); push(v5); }
3.26
hmily_HmilyRepositoryEventPublisher_asyncPublishEvent_rdh
/** * Async publish event. * * @param hmilyTransaction * the hmily transaction * @param type * the type */ public void asyncPublishEvent(final HmilyTransaction hmilyTransaction, final int type) { HmilyRepositoryEvent event = new HmilyRepositoryEvent(); event.setType(type); event.setHmilyTransaction(hmilyTransaction); event.setTransId(hmilyTransaction.getTransId()); disruptor.getProvider().onData(event); }
3.26
hmily_Binder_setProperty_rdh
/** * Sets property. * * @param property * the property */public void setProperty(final ConfigProperty property) { this.property = property; }
3.26
hmily_Binder_bind_rdh
/** * Bind object. * * @param <T> * the type parameter * @param name * the name * @param target * the target * @param env * the env * @param allowRecursiveBinding * the allow recursive binding * @return the object */ protected <T> Object bind(final PropertyName name, final BindData<T> target, final Env env, final boolean allowRecursiveBinding) { return bindObject(name, target, env, allowRecursiveBinding); }
3.26
hmily_Binder_setSource_rdh
/** * Sets source. * * @param source * the source * @param value * the value * @return the source */ Object setSource(final ConfigPropertySource source, final Supplier<?> value) { this.source = source;return value.get(); }
3.26
hmily_Binder_of_rdh
/** * Of binder. * * @param source * the source * @return the binder */ public static Binder of(final ConfigPropertySource source) { return new Binder(source); }
3.26
hmily_Binder_getSource_rdh
/** * Gets source. * * @return the source */ ConfigPropertySource getSource() { if (source == null) { return Binder.this.source; }return source; }
3.26
hmily_ApolloClient_pull_rdh
/** * Pull input stream. * * @param config * the config * @return the input stream */ public InputStream pull(final ApolloConfig config) { setApolloConfig(config); ConfigFile configFile = ConfigService.getConfigFile(config.getNamespace(), ConfigFileFormat.fromString(config.getFileExtension())); String content = configFile.getContent(); if (LOGGER.isDebugEnabled()) {LOGGER.debug("apollo content {}", content); } if (StringUtils.isBlank(content)) { return null; } return new ByteArrayInputStream(content.getBytes());}
3.26
hmily_HmilyUndoContextCacheManager_set_rdh
/** * Set undo context. * * @param undoContext * hmily undo context */ public void set(final HmilyUndoContext undoContext) { CURRENT_LOCAL.get().add(undoContext); }
3.26
hmily_HmilyBootstrap_start_rdh
/** * hmily initialization. */ public void start() { try { ConfigLoaderServer.load(); HmilyConfig hmilyConfig = ConfigEnv.getInstance().getConfig(HmilyConfig.class); m1(hmilyConfig); registerProvide();loadHmilyRepository(hmilyConfig); registerAutoCloseable(new HmilyTransactionSelfRecoveryScheduled(), HmilyRepositoryEventPublisher.getInstance()); m0(); } catch (Exception e) { LOGGER.error(" hmily init exception:", e); System.exit(0); } new HmilyLogo().logo(); }
3.26
hmily_XaResourceWrapped_rollback0_rdh
/** * 子类实现. Rollback 0. * * @param xid * the xid * @throws XAException * the xa exception */ void rollback0(final Xid xid) throws XAException { }
3.26
hmily_XaResourceWrapped_start0_rdh
/** * 子类实现. Start 0. * * @param xid * the xid * @param flag * the flag * @throws XAException * the xa exception */ void start0(final Xid xid, final int flag) throws XAException { }
3.26
hmily_XaResourceWrapped_commit0_rdh
/** * 子类实现. Commit 0. * * @param xid * the xid * @param onePhase * the one phase * @throws XAException * the xa exception */ void commit0(final Xid xid, final boolean onePhase) throws XAException { }
3.26
hmily_GsonUtils_toTreeMap_rdh
/** * To tree map tree map. * * @param json * the json * @return the tree map */ public ConcurrentSkipListMap<String, Object> toTreeMap(final String json) { return GSON_MAP.fromJson(json, new TypeToken<ConcurrentSkipListMap<String, Object>>() {}.getType()); }
3.26
hmily_GsonUtils_toObjectMap_rdh
/** * To object map map. * * @param json * the json * @return the map */ public Map<String, Object> toObjectMap(final String json) { return GSON_MAP.fromJson(json, new TypeToken<LinkedHashMap<String, Object>>() {}.getType()); }
3.26
hmily_GsonUtils_getGson_rdh
/** * Gets gson instance. * * @return the instance */ public static Gson getGson() { return GsonUtils.GSON; }
3.26
hmily_GsonUtils_toStringMap_rdh
/** * toMap. * * @param json * json * @return hashMap map */ private Map<String, String> toStringMap(final String json) { return GSON.fromJson(json, new TypeToken<Map<String, String>>() {}.getType()); }
3.26
hmily_GsonUtils_getInstance_rdh
/** * Gets instance. * * @return the instance */public static GsonUtils getInstance() { return INSTANCE; }
3.26
hmily_GsonUtils_fromList_rdh
/** * From list list. * * @param <T> * the type parameter * @param json * the json * @param clazz * the clazz * @return the list */ public <T> List<T> fromList(final String json, final Class<T> clazz) { return GSON.fromJson(json, TypeToken.getParameterized(List.class, clazz).getType()); }
3.26
hmily_GsonUtils_getType_rdh
/** * Get JsonElement class type. * * @param element * the element * @return Class class */ public Class getType(final JsonElement element) { if (!element.isJsonPrimitive()) { return element.getClass(); } final JsonPrimitive primitive = element.getAsJsonPrimitive(); if (primitive.isString()) { return String.class; } else if (primitive.isNumber()) { String numStr = primitive.getAsString(); if ((numStr.contains(DOT) || numStr.contains(E)) || numStr.contains("E")) { return Double.class; } return Long.class; } else if (primitive.isBoolean()) { return Boolean.class; } else { return element.getClass(); } }
3.26
hmily_GsonUtils_fromJson_rdh
/** * From json t. * * @param <T> * the type parameter * @param jsonElement * the json element * @param tClass * the t class * @return the t */ public <T> T fromJson(final JsonElement jsonElement, final Class<T> tClass) { return GSON.fromJson(jsonElement, tClass); }
3.26
hmily_GsonUtils_toJson_rdh
/** * To json string. * * @param object * the object * @return the string */ public String toJson(final Object object) { return GSON.toJson(object); }
3.26
hmily_GsonUtils_toListMap_rdh
/** * toList Map. * * @param json * json * @return hashMap list */ public List<Map<String, Object>> toListMap(final String json) { return GSON.fromJson(json, new TypeToken<List<Map<String, Object>>>() {}.getType()); }
3.26
hmily_HmilyXaStatement_associateXa_rdh
/** * Associate xa tm. * * @param <T> * the type parameter * @param called * the called * @return the t * @throws SQLException * the sql exception */ public <T> T associateXa(final Called<T> called) throws SQLException { Transaction tx = TransactionManagerImpl.INST.getTransaction(); if (tx != null) { XAConnection xaConnection = getXaConnection(); try { if (!TransactionManagerImpl.INST.isExistDataSources(xaConnection)) { if (tx instanceof TransactionImpl) { ((TransactionImpl) (tx)).doEnList(xaConnection.getXAResource(), XAResource.TMJOIN); } } } catch (RollbackException | SystemException | SQLException e) { e.printStackTrace(); } } return called.call(); }
3.26
hmily_HmilyXaStatement_getXaConnection_rdh
/** * Gets xa connection. * * @return the xa connection */ public synchronized XAConnection getXaConnection() { if (this.xaConnection == null) { throw new IllegalArgumentException("connection not implements XAConnection"); } return xaConnection; }
3.26
hmily_SpringCloudHmilyAccountApplication_main_rdh
/** * The entry point of application. * * @param args * the input arguments */ public static void main(final String[] args) { SpringApplication.run(SpringCloudHmilyAccountApplication.class, args); }
3.26
hmily_AbstractHmilySQLComputeEngine_buildTuple_rdh
/** * Build tuple. * * @param tableName * table name * @param manipulation * manipulation * @param primaryKeyValues * primary key values * @param before * before * @param after * after * @return hmily SQL tuple */ protected HmilySQLTuple buildTuple(final String tableName, final HmilySQLManipulation manipulation, final List<Object> primaryKeyValues, final Map<String, Object> before, final Map<String, Object> after) {HmilySQLTuple result = new HmilySQLTuple(); result.setTableName(tableName); result.setManipulationType(manipulation); result.setPrimaryKeyValues(primaryKeyValues); result.setBeforeImage(before); result.setAfterImage(after); return result; }
3.26
hmily_HmilyUpdateStatement_getWhere_rdh
/** * Get where. * * @return where segment */ public Optional<HmilyWhereSegment> getWhere() { return Optional.ofNullable(where); }
3.26
hmily_HashedWheelTimer_addTimeout_rdh
/** * Add {@link HashedWheelTimeout} to this bucket. */ public void addTimeout(final HashedWheelTimeout timeout) { assert timeout.bucket == null; timeout.bucket = this; if (head == null) {head = tail = timeout; } else { tail.next = timeout; timeout.prev = tail; tail = timeout; } }
3.26
hmily_HashedWheelTimer_processCancelledTasks_rdh
/** * 流程任务取消;从取消队列中获取任务。并删除. */ private void processCancelledTasks() { for (; ;) { HashedWheelTimeout timeout = cancelledTimeouts.poll(); if (timeout == null) { // all processed break; } try { timeout.remove(); } catch (Throwable t) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("An exception was thrown while process a cancellation task", t); } } } }
3.26
hmily_HashedWheelTimer_start_rdh
/** * 启动任务. */ public void start() { switch (WORKER_STATE_UPDATER.get(this)) { // 更改线程状态;如果当前的状态是初始,则改成启动中; case WORKER_STATE_INIT : if (WORKER_STATE_UPDATER.compareAndSet(this, WORKER_STATE_INIT, WORKER_STATE_STARTED)) { // 启动线程; workerThread.start(); } break; case WORKER_STATE_STARTED : break; case WORKER_STATE_SHUTDOWN : throw new IllegalStateException("cannot be started once stopped"); default : throw new Error("Invalid WorkerState"); } // 等待初始化的Worker线程的startTime实始化; while (startTime == 0) { try { startTimeInitialized.await(); } catch (InterruptedException ignore) { // Ignore - it will be ready very soon. } } }
3.26
hmily_HashedWheelTimer_clearTimeouts_rdh
/** * Clear this bucket and return all not expired / cancelled {@link Timeout}s. */ public void clearTimeouts(final Set<Timeout> set) { for (; ;) { HashedWheelTimeout timeout = pollTimeout(); if (timeout == null) { return; } if (timeout.isExpired() || timeout.isCancelled()) { continue; } set.add(timeout); } }
3.26
hmily_HashedWheelTimer_expireTimeouts_rdh
/** * Expire all {@link HashedWheelTimeout}s for the given {@code deadline}. */ public void expireTimeouts(final long deadline) { HashedWheelTimeout timeout = head; // process all timeouts while (timeout != null) { boolean remove = false; if (timeout.f0 <= 0) { if (timeout.deadline <= deadline) { timeout.expire(); } else { // The timeout was placed into a wrong slot. This should never happen. throw new IllegalStateException(String.format("timeout.deadline (%d) > deadline (%d)", timeout.deadline, deadline)); } remove = true; } else if (timeout.isCancelled()) { remove = true; } else { timeout.f0--; } // store reference to next as we may null out timeout.next in the remove block. HashedWheelTimeout next = timeout.next; if (remove) { remove(timeout); } timeout = next; } }
3.26
hmily_MotanConfig_motanAnnotationBean_rdh
/** * Motan annotation bean annotation bean. * * @return the annotation bean */ @Bean @ConfigurationProperties(prefix = "hmily.motan.annotation") public AnnotationBean motanAnnotationBean() { return new AnnotationBean(); }
3.26
hmily_InLineServiceImpl_confirm_rdh
/** * Confrim. */ public void confirm() { System.out.println("执行inline confirm......"); }
3.26
hmily_InLineServiceImpl_m1_rdh
/** * Cancel. */ public void m1() { System.out.println("执行inline cancel......"); }
3.26
hmily_HmilySafeNumberOperationUtils_safeEquals_rdh
/** * Execute collection equals method by safe mode. * * @param sourceCollection * source collection * @param targetCollection * target collection * @return whether the element in source collection and target collection are all same */ public static boolean safeEquals(final Collection<Comparable<?>> sourceCollection, final Collection<Comparable<?>> targetCollection) { List<Comparable<?>> collection = Lists.newArrayList(sourceCollection); collection.addAll(targetCollection); Class<?> clazz = m1(collection); if (null == clazz) { return sourceCollection.equals(targetCollection); } List<Comparable<?>> sourceClazzCollection = sourceCollection.stream().map(number -> parseNumberByClazz(number.toString(), clazz)).collect(Collectors.toList()); List<Comparable<?>> targetClazzCollection = targetCollection.stream().map(number -> parseNumberByClazz(number.toString(), clazz)).collect(Collectors.toList()); return sourceClazzCollection.equals(targetClazzCollection); }
3.26
hmily_HmilySafeNumberOperationUtils_safeIntersection_rdh
/** * Execute range intersection method by safe mode. * * @param range * range * @param connectedRange * connected range * @return the intersection result of two ranges */ public static Range<Comparable<?>> safeIntersection(final Range<Comparable<?>> range, final Range<Comparable<?>> connectedRange) { try { return range.intersection(connectedRange); } catch (final ClassCastException ex) { Comparable<?> rangeLowerEndpoint = (range.hasLowerBound()) ? range.lowerEndpoint() : null; Comparable<?> rangeUpperEndpoint = (range.hasUpperBound()) ? range.upperEndpoint() : null; Comparable<?> connectedRangeLowerEndpoint = (connectedRange.hasLowerBound()) ? connectedRange.lowerEndpoint() : null; Comparable<?> connectedRangeUpperEndpoint = (connectedRange.hasUpperBound()) ? connectedRange.upperEndpoint() : null; Class<?> clazz = m1(Lists.newArrayList(rangeLowerEndpoint, rangeUpperEndpoint, connectedRangeLowerEndpoint, connectedRangeUpperEndpoint)); if (clazz == null) { throw ex; } Range<Comparable<?>> newRange = createTargetNumericTypeRange(range, clazz); Range<Comparable<?>> newConnectedRange = createTargetNumericTypeRange(connectedRange, clazz); return newRange.intersection(newConnectedRange);} }
3.26
hmily_HmilySafeNumberOperationUtils_safeContains_rdh
/** * Execute range contains method by safe mode. * * @param range * range * @param endpoint * endpoint * @return whether the endpoint is included in the range */ public static boolean safeContains(final Range<Comparable<?>> range, final Comparable<?> endpoint) { try { return range.contains(endpoint); } catch (final ClassCastException ex) { Comparable<?> rangeUpperEndpoint = (range.hasUpperBound()) ? range.upperEndpoint() : null; Comparable<?> rangeLowerEndpoint = (range.hasLowerBound()) ? range.lowerEndpoint() : null; Class<?> clazz = m1(Lists.newArrayList(rangeLowerEndpoint, rangeUpperEndpoint, endpoint)); if (clazz == null) { throw ex; } Range<Comparable<?>> newRange = createTargetNumericTypeRange(range, clazz); return newRange.contains(parseNumberByClazz(endpoint.toString(), clazz)); } }
3.26
hmily_HmilySafeNumberOperationUtils_m0_rdh
/** * Execute range closed method by safe mode. * * @param lowerEndpoint * lower endpoint * @param upperEndpoint * upper endpoint * @return new range */ public static Range<Comparable<?>> m0(final Comparable<?> lowerEndpoint, final Comparable<?> upperEndpoint) { try { return Range.closed(lowerEndpoint, upperEndpoint); } catch (final ClassCastException ex) { Class<?> clazz = m1(Lists.newArrayList(lowerEndpoint, upperEndpoint)); if (clazz == null) { throw ex; } return Range.closed(parseNumberByClazz(lowerEndpoint.toString(), clazz), parseNumberByClazz(upperEndpoint.toString(), clazz));} }
3.26
hmily_HmilyRepositoryNode_getRootPathPrefix_rdh
/** * Get root path prefix. * * @return root path prefix */public String getRootPathPrefix() { return ROOT_PATH_PREFIX; }
3.26
hmily_HmilyRepositoryNode_getHmilyParticipantUndoRootPath_rdh
/** * Get hmily participant undo root path. * * @return hmily participant undo root path */ public String getHmilyParticipantUndoRootPath() { return Joiner.on("/").join("", ROOT_PATH_PREFIX, appName, HMILY_PARTICIPANT_UNDO); }
3.26
hmily_HmilyRepositoryNode_getHmilyLockRootPath_rdh
/** * Get hmily lock root path. * * @return hmily lock root path */ public String getHmilyLockRootPath() { return Joiner.on("/").join("", ROOT_PATH_PREFIX, appName, HMILY_LOCK_GLOBAL); }
3.26
hmily_HmilyRepositoryNode_getHmilyParticipantRealPath_rdh
/** * Get hmily participant real path. * * @param participantId * participant id * @return hmily participant real path */ public String getHmilyParticipantRealPath(final Long participantId) { return Joiner.on("/").join(getHmilyParticipantRootPath(), participantId); }
3.26
hmily_HmilyRepositoryNode_getHmilyLockRealPath_rdh
/** * Get hmily lock real path. * * @param lockId * lock id * @return hmily lock real path */ public String getHmilyLockRealPath(final String lockId) { return Joiner.on("/").join(getHmilyLockRootPath(), lockId); }
3.26
hmily_HmilyRepositoryNode_getHmilyTransactionRealPath_rdh
/** * Get hmily transaction real path. * * @param transactionId * transaction id * @return hmily transaction real path */ public String getHmilyTransactionRealPath(final Long transactionId) { return Joiner.on("/").join(m0(), transactionId); }
3.26
hmily_HmilyRepositoryNode_m0_rdh
/** * Get hmily transaction root path. * * @return hmily transaction root path */ public String m0() { return Joiner.on("/").join("", ROOT_PATH_PREFIX, appName, HMILY_TRANSACTION_GLOBAL); }
3.26
hmily_HmilyRepositoryNode_getHmilyParticipantUndoRealPath_rdh
/** * Get hmily participant undo real path. * * @param undoId * undo id * @return hmily participant undo real path */ public String getHmilyParticipantUndoRealPath(final Long undoId) { return Joiner.on("/").join(getHmilyParticipantUndoRootPath(), undoId); }
3.26
hmily_ExpressionHandler_getValue_rdh
/** * Get expression value. * * @param parameters * SQL parameters * @param expressionSegment * expression segment * @return expression value */ public static Object getValue(final List<Object> parameters, final HmilyExpressionSegment expressionSegment) { if (expressionSegment instanceof HmilyCommonExpressionSegment) { String value = ((HmilyCommonExpressionSegment) (expressionSegment)).getText(); return "null".equals(value) ? null : value; } if (expressionSegment instanceof HmilyParameterMarkerExpressionSegment) { return parameters.get(((HmilyParameterMarkerExpressionSegment) (expressionSegment)).getParameterMarkerIndex()); } if (expressionSegment instanceof HmilyExpressionProjectionSegment) { String value = ((HmilyExpressionProjectionSegment) (expressionSegment)).getText(); return "null".equals(value) ? null : value; } if (expressionSegment instanceof HmilyBinaryOperationExpression) { Object left = getValue(parameters, ((HmilyBinaryOperationExpression) (expressionSegment)).getLeft()); Object right = getValue(parameters, ((HmilyBinaryOperationExpression) (expressionSegment)).getRight()); return String.format("%s %s %s", left, ((HmilyBinaryOperationExpression) (expressionSegment)).getOperator(), right); } if (expressionSegment instanceof HmilyColumnSegment) { return ((HmilyColumnSegment) (expressionSegment)).getQualifiedName(); } // TODO match result type with metadata return ((HmilyLiteralExpressionSegment) (expressionSegment)).getLiterals(); }
3.26
hmily_HmilyParticipantUndo_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_FileRepository_clean_rdh
/** * The file handle is occupied help gc clean buffer. * http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4724038 * * @param buffer * buffer */ public static void clean(final ByteBuffer buffer) { if (((buffer == null) || (!buffer.isDirect())) || (buffer.capacity() == 0)) { return; } invoke(invoke(m1(buffer), "cleaner"), "clean"); }
3.26
hmily_RejectedPolicyTypeEnum_fromString_rdh
/** * From string rejected policy type enum. * * @param value * the value * @return the rejected policy type enum */ public static RejectedPolicyTypeEnum fromString(final String value) { Optional<RejectedPolicyTypeEnum> rejectedPolicyTypeEnum = Arrays.stream(RejectedPolicyTypeEnum.values()).filter(v -> Objects.equals(v.getValue(), value)).findFirst(); return rejectedPolicyTypeEnum.orElse(RejectedPolicyTypeEnum.ABORT_POLICY); }
3.26
hmily_BrpcHmilyOrderApplication_main_rdh
/** * main. * * @param args * args */ public static void main(final String[] args) { SpringApplication.run(BrpcHmilyOrderApplication.class, args); }
3.26
hmily_HmilySQLComputeEngineFactory_newInstance_rdh
/** * Create new instance of hmily SQL compute engine. * * @param hmilyStatement * hmily statement * @return Hmily SQL compute engine * @throws SQLComputeException * SQL compute Exception */ public static HmilySQLComputeEngine newInstance(final HmilyStatement hmilyStatement) throws SQLComputeException { if (hmilyStatement instanceof HmilyMySQLInsertStatement) { return new HmilyInsertSQLComputeEngine(((HmilyMySQLInsertStatement) (hmilyStatement)));} else if (hmilyStatement instanceof HmilyMySQLUpdateStatement) { return new HmilyUpdateSQLComputeEngine(((HmilyMySQLUpdateStatement) (hmilyStatement))); } else if (hmilyStatement instanceof HmilyMySQLDeleteStatement) {return new HmilyDeleteSQLComputeEngine(((HmilyMySQLDeleteStatement) (hmilyStatement))); } else if (hmilyStatement instanceof HmilyMySQLSelectStatement) { return new HmilySelectSQLComputeEngine(((HmilyMySQLSelectStatement) (hmilyStatement))); } else { throw new SQLComputeException(String.format("do not support hmily SQL compute yet, SQLStatement:{%s}.", hmilyStatement)); } }
3.26
hmily_DefaultAnnotationField_check_rdh
/** * The type Default annotation field. * * @author xiaoyu */public class DefaultAnnotationField implements AnnotationField { @Overridepublic boolean check(final Field field) { return false; }
3.26
hmily_StringUtils_isNoneBlank_rdh
/** * Is none blank boolean. * * @param css * the css * @return the boolean */ public static boolean isNoneBlank(final CharSequence... css) { return !isAnyBlank(css); }
3.26
hmily_StringUtils_isAnyBlank_rdh
/** * Is any blank boolean. * * @param css * the css * @return the boolean */ private static boolean isAnyBlank(final CharSequence... css) { if (isEmpty(css)) { return true; } for (CharSequence cs : css) { if (isBlank(cs)) { return true; } } return false; }
3.26
hmily_StringUtils_isEmpty_rdh
/** * Is empty boolean. * * @param array * the array * @return the boolean */ public static boolean isEmpty(final Object[] array) { return (array == null) || (array.length == 0);}
3.26
hmily_StringUtils_isBlank_rdh
/** * Is blank boolean. * * @param cs * the cs * @return the boolean */ public static boolean isBlank(final CharSequence cs) { int strLen;if ((cs == null) || ((strLen = cs.length()) == 0)) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; }
3.26
hmily_LogUtil_warn_rdh
/** * Warn. * * @param logger * the logger * @param supplier * the supplier */ public static void warn(final Logger logger, final Supplier<Object> supplier) { if (logger.isWarnEnabled()) { logger.warn(Objects.toString(supplier.get())); } }
3.26
hmily_LogUtil_info_rdh
/** * Info. * * @param logger * the logger * @param supplier * the supplier */ public static void info(final Logger logger, final Supplier<Object> supplier) { if (logger.isInfoEnabled()) { logger.info(Objects.toString(supplier.get())); } }
3.26
hmily_LogUtil_getInstance_rdh
/** * Gets instance. * * @return the instance */public static LogUtil getInstance() { return LOG_UTIL; }
3.26