name
stringlengths 12
178
| code_snippet
stringlengths 8
36.5k
| score
float64 3.26
3.68
|
---|---|---|
hmily_CuratorZookeeperClient_pull_rdh | /**
* Pull input stream.
*
* @param path
* the path
* @return the input stream
*/public InputStream pull(final String path)
{String content = get(path);if (LOGGER.isDebugEnabled()) {
LOGGER.debug("zookeeper content {}", content);
}
if (StringUtils.isBlank(content)) {
return null;
}
return new ByteArrayInputStream(content.getBytes());
} | 3.26 |
hmily_CuratorZookeeperClient_get_rdh | /**
* Get string.
*
* @param path
* the path
* @return the string
*/
public String get(final String path) {
CuratorCache cache = findTreeCache(path);
if (null == cache) {
return getDirectly(path);
}
Optional<ChildData> resultInCache =
cache.get(path);
if (resultInCache.isPresent()) {
return null == resultInCache.get().getData() ? null : new String(resultInCache.get().getData(), Charsets.UTF_8);
}return getDirectly(path);
} | 3.26 |
hmily_TableMetaData_isPrimaryKey_rdh | /**
* Judge column whether primary key.
*
* @param columnIndex
* column index
* @return true if the column is primary key, otherwise false
*/
public boolean isPrimaryKey(final int columnIndex) {
return (columnIndex
< columnNames.size()) && columns.get(columnNames.get(columnIndex)).isPrimaryKey();
} | 3.26 |
hmily_TableMetaData_findColumnIndex_rdh | /**
* Find index of column.
*
* @param columnName
* column name
* @return index of column if found, otherwise -1
*/
public int
findColumnIndex(final String columnName) {
for (int i = 0; i < columnNames.size(); i++) {
if (columnNames.get(i).equals(columnName)) {
return i;
}
}
return -1;
} | 3.26 |
hmily_TableMetaData_getColumnMetaData_rdh | /**
* Get column meta data.
*
* @param columnIndex
* column index
* @return column meta data
*/
public ColumnMetaData getColumnMetaData(final int columnIndex) {
return columns.get(columnNames.get(columnIndex));
} | 3.26 |
hmily_DubboHmilyAccountApplication_main_rdh | /**
* main.
*
* @param args
* args.
*/
public static void main(final String[] args) {
SpringApplication springApplication =
new SpringApplication(DubboHmilyAccountApplication.class);
springApplication.setWebApplicationType(WebApplicationType.NONE);
springApplication.run(args);
} | 3.26 |
hmily_ExtensionLoader_setValue_rdh | /**
* Sets value.
*
* @param value
* the value
*/
public void
setValue(final T value) {
this.value = value;
} | 3.26 |
hmily_ExtensionLoader_load_rdh | /**
* Load t.
*
* @param name
* the name
* @param argsType
* the args type
* @param args
* the args
* @param loader
* the loader
* @return the t
*/
public T load(final String name, final Class<?>[] argsType, final Object[] args, final ClassLoader loader) {
return loadExtension(name, loader, argsType, args);
} | 3.26 |
hmily_ExtensionLoader_loadAll_rdh | /**
* Load all list.
*
* @param loader
* the loader
* @return the list
*/
public List<T> loadAll(final ClassLoader loader) {
return loadAll(null, null, loader);
} | 3.26 |
hmily_ExtensionLoader_getValue_rdh | /**
* Gets value.
*
* @return the value
*/
public T getValue() {
return value;
} | 3.26 |
hmily_ExtensionLoader_getExtensionLoader_rdh | /**
* Gets extension loader.
*
* @param <T>
* the type parameter
* @param clazz
* the clazz
* @return the extension loader
*/
public static <T> ExtensionLoader<T> getExtensionLoader(final Class<T> clazz) {
if (clazz == null) {
throw new NullPointerException("extension clazz is null");
}
if (!clazz.isInterface()) {
throw new IllegalArgumentException(("extension clazz (" + clazz) + "is not interface!");
}
ExtensionLoader<T> extensionLoader = ((ExtensionLoader<T>) (LOADERS.get(clazz)));
if (extensionLoader != null) {
return extensionLoader;
}
LOADERS.putIfAbsent(clazz, new ExtensionLoader<>(clazz));
return ((ExtensionLoader<T>) (LOADERS.get(clazz)));
} | 3.26 |
hmily_RpcMediator_transmit_rdh | /**
* Transmit.
*
* @param <T>
* the type parameter
* @param rpcTransmit
* the rpc transmit
* @param context
* the context
*/
public <T> void transmit(final RpcTransmit rpcTransmit, final T context) {
if (Objects.nonNull(context)) {
rpcTransmit.transmit(CommonConstant.HMILY_TRANSACTION_CONTEXT, GsonUtils.getInstance().toJson(context));
}
} | 3.26 |
hmily_RpcMediator_getAndSet_rdh | /**
* Gets and set.
*
* @param function
* the function
* @param biConsumer
* the bi consumer
*/
public void getAndSet(final Function<String, Object> function, final BiConsumer<String, Object> biConsumer) {
Object result = function.apply(CommonConstant.HMILY_TRANSACTION_CONTEXT);
if (Objects.nonNull(result)) {
biConsumer.accept(CommonConstant.HMILY_TRANSACTION_CONTEXT, result);
}
} | 3.26 |
hmily_RpcMediator_acquire_rdh | /**
* Acquire hmily transaction context.
*
* @param <T>
* the type parameter
* @param rpcAcquire
* the rpc acquire
* @param clazz
* the clazz
* @return the hmily transaction context
*/
public <T> T acquire(final RpcAcquire rpcAcquire, final Class<T> clazz) {
T hmilyTransactionContext = null;
final String context = rpcAcquire.acquire(CommonConstant.HMILY_TRANSACTION_CONTEXT);
if (StringUtils.isNoneBlank(context)) {
hmilyTransactionContext = GsonUtils.getInstance().fromJson(context, clazz);}
return hmilyTransactionContext;} | 3.26 |
hmily_RpcMediator_getInstance_rdh | /**
* Gets instance.
*
* @return the instance
*/
public static RpcMediator getInstance() {
return INSTANCE;
} | 3.26 |
hmily_EventTypeEnum_buildByCode_rdh | /**
* Build by code event type enum.
*
* @param code
* the code
* @return the event type enum
*/
public static EventTypeEnum buildByCode(final int code) {
return Arrays.stream(EventTypeEnum.values()).filter(e -> e.code == code).findFirst().orElseThrow(() -> new HmilyRuntimeException("can not support this code!"));
} | 3.26 |
hmily_HmilyShutdownHook_registerAutoCloseable_rdh | /**
* Register auto closeable.
*
* @param autoCloseable
* the auto closeable
*/
public void registerAutoCloseable(final AutoCloseable autoCloseable) {
autoCloseableHashSet.add(autoCloseable);
} | 3.26 |
hmily_ExtensionLoaderFactory_loadAll_rdh | /**
* Load all list.
*
* @param <T>
* the type parameter
* @param service
* the service
* @return the list
*/
public static <T> List<T> loadAll(final Class<T> service) {
return ExtensionLoader.getExtensionLoader(service).loadAll(findClassLoader());
} | 3.26 |
hmily_ExtensionLoaderFactory_load_rdh | /**
* Load t.
*
* @param <T>
* the type parameter
* @param service
* the service
* @param name
* the name
* @param argsType
* the args type
* @param args
* the args
* @return the t
*/
public static <T> T load(final Class<T> service, final String name, final Class<?>[] argsType, final Object[] args) {
return ExtensionLoader.getExtensionLoader(service).load(name, argsType, args, findClassLoader());
} | 3.26 |
hmily_ThreadLocalHmilyContext_set_rdh | /**
* set value.
*
* @param context
* context
*/
public void set(final HmilyTransactionContext context) {
CURRENT_LOCAL.set(context);
} | 3.26 |
hmily_ThreadLocalHmilyContext_get_rdh | /**
* get value.
*
* @return TccTransactionContext
*/
public HmilyTransactionContext get() {
return CURRENT_LOCAL.get();
} | 3.26 |
hmily_SubCoordinator_setRollbackOnly_rdh | /**
* Sets rollback only.
*/
public void setRollbackOnly() {
if (state == XaState.STATUS_PREPARING) {
state = XaState.STATUS_MARKED_ROLLBACK;
}
} | 3.26 |
hmily_SubCoordinator_doOnePhaseCommit_rdh | /**
* 表示为第一阶断的直接提交.
*/
private void doOnePhaseCommit() throws TransactionRolledbackException {
state = XaState.STATUS_COMMITTING;HmilyXaResource xaResource = ((HmilyXaResource) (resources.get(0)));
try {
xaResource.commit(true);
state = XaState.STATUS_COMMITTED;
}
catch (XAException ex) {
state = XaState.STATUS_UNKNOWN;logger.error("xa commit error{}:{}", xaResource, HmilyXaException.getMessage(ex));
if (Objects.equals(ex.errorCode,
XAException.XA_RBROLLBACK)) {
throw new TransactionRolledbackException("XAException:" + ex.getMessage());
}
throw new RuntimeException("XAException" + ex.getMessage());
} finally {
afterCompletion();
}
} | 3.26 |
hmily_SubCoordinator_doCommit_rdh | /**
* 2pc.
*/
private synchronized void doCommit() {
state = XaState.STATUS_COMMITTING;
int commitError = 0;
for (int i = 0; i < resources.size(); i++) {
HmilyXaResource v12 = ((HmilyXaResource) (resources.elementAt(i)));
try {
// false is 2pc.
v12.commit(false);
if (logger.isDebugEnabled()) {
logger.debug("xa commit{}", v12.getXid());
}
} catch (XAException e) {
logger.error("rollback error,{}:{}", v12.getXid(), HmilyXaException.getMessage(e));
commitError++;
}
}
if (commitError > 0) {
state = XaState.STATUS_UNKNOWN;
} else {
state = XaState.STATUS_COMMITTED;
}
afterCompletion();
} | 3.26 |
hmily_SubCoordinator_addSynchronization_rdh | /**
* Add synchronization boolean.
*
* @param synchronization
* the synchronization
* @throws RollbackException
* the rollback exception
*/
public synchronized void addSynchronization(final Synchronization synchronization) throws RollbackException {
if (state == XaState.STATUS_ACTIVE) {
synchronizations.add(synchronization);
return;
}
if ((state == XaState.STATUS_MARKED_ROLLBACK) || (state == XaState.STATUS_ROLLEDBACK)) {synchronizations.add(synchronization);
throw new RollbackException();
}
} | 3.26 |
hmily_SubCoordinator_addXaResource_rdh | /**
* Add a xa Resource.
*
* @param xaResource
* the xa resource
* @return boolean boolean
*/
public synchronized boolean addXaResource(final XAResource
xaResource) {
switch (state) {
case STATUS_MARKED_ROLLBACK :
break;
case STATUS_ACTIVE :
break;
default :
throw new RuntimeException("status == " + state);
}
Optional<XAResource> isSame = resources.stream().filter(e -> {
try {
return e.isSameRM(xaResource);
} catch (XAException
xaException) {
logger.error("xa isSameRM,{}:{}", xaException, HmilyXaException.getMessage(xaException));
return false;
}
}).findFirst();
if (!isSame.isPresent()) {
this.resources.add(xaResource);
return false;
}
return true;
} | 3.26 |
hmily_SubCoordinator_nextXid_rdh | /**
* Next xid x id.
*
* @param xId
* the x id
* @return the x id
*/
public synchronized XidImpl nextXid(final XidImpl xId) {
return xId.newResId(this.resources.size() + 1);
} | 3.26 |
hmily_DbTypeUtils_buildByDriverClassName_rdh | /**
* check db type.
*
* @param driverClassName
* driverClassName
* @return mysql sqlserver oracle postgresql.
*/
public static String buildByDriverClassName(final String driverClassName) {
String dbType = null;
if (driverClassName.contains(CommonConstant.DB_MYSQL)) {
dbType = CommonConstant.DB_MYSQL;
} else if (driverClassName.contains(CommonConstant.DB_SQLSERVER)) {
dbType = CommonConstant.DB_SQLSERVER;
} else if (driverClassName.contains(CommonConstant.DB_ORACLE)) {
dbType = CommonConstant.DB_ORACLE;
} else if (driverClassName.contains(CommonConstant.DB_POSTGRESQL)) {
dbType = CommonConstant.DB_POSTGRESQL;
}
return dbType;
} | 3.26 |
hmily_TarsHmilyConfiguration_hmilyCommunicatorBeanPostProcessor_rdh | /**
* add HmilyCommunicatorBeanPostProcessor and override old old tars's bean post processor.
*
* @author tydhot
*/
@Configuration public class TarsHmilyConfiguration {
/**
* add HmilyCommunicatorBeanPostProcessor.
*
* @param communicator
* communicator
* @return HmilyCommunicatorBeanPostProcessor
*/
@Bean
public TarsHmilyCommunicatorBeanPostProcessor hmilyCommunicatorBeanPostProcessor(final Communicator communicator) {
return new TarsHmilyCommunicatorBeanPostProcessor(communicator);
} | 3.26 |
hmily_HmilySQLRevertEngineFactory_newInstance_rdh | /**
* New instance hmily SQL revert engine.
*
* @return the hmily SQL revert engine
*/
public static HmilySQLRevertEngine newInstance() {
if (hmilySqlRevertEngine == null) {
synchronized(HmilySQLRevertEngineFactory.class) {
if (hmilySqlRevertEngine == null) {HmilyConfig config = ConfigEnv.getInstance().getConfig(HmilyConfig.class);
hmilySqlRevertEngine = ExtensionLoaderFactory.load(HmilySQLRevertEngine.class, config.getSqlRevert());
}
}
}return hmilySqlRevertEngine;
} | 3.26 |
hmily_HmilyParticipantCacheManager_removeByKey_rdh | /**
* remove guava cache by key.
*
* @param participantId
* guava cache key.
*/
public void removeByKey(final Long participantId) {
if (Objects.nonNull(participantId)) {
LOADING_CACHE.invalidate(participantId);
}
} | 3.26 |
hmily_HmilyParticipantCacheManager_get_rdh | /**
* acquire hmilyTransaction.
*
* @param participantId
* this guava key.
* @return {@linkplain HmilyTransaction}
*/
public List<HmilyParticipant> get(final Long participantId) {
try {
return LOADING_CACHE.get(participantId);
} catch (ExecutionException e) {
return Collections.emptyList();
}
} | 3.26 |
hmily_HmilyParticipantCacheManager_cacheHmilyParticipant_rdh | /**
* Cache hmily participant.
*
* @param participantId
* the participant id
* @param hmilyParticipant
* the hmily participant
*/
public void cacheHmilyParticipant(final Long participantId, final HmilyParticipant hmilyParticipant) {
List<HmilyParticipant> existHmilyParticipantList = get(participantId);
if (CollectionUtils.isEmpty(existHmilyParticipantList)) {
LOADING_CACHE.put(participantId, Lists.newArrayList(hmilyParticipant));
} else {
existHmilyParticipantList.add(hmilyParticipant);LOADING_CACHE.put(participantId, existHmilyParticipantList);
}
} | 3.26 |
hmily_HmilyTransactionHolder_getCurrentTransaction_rdh | /**
* acquired by threadLocal.
*
* @return {@linkplain HmilyTransaction}
*/
public HmilyTransaction getCurrentTransaction() {
return CURRENT.get();
} | 3.26 |
hmily_HmilyTransactionHolder_cacheHmilyParticipant_rdh | /**
* Cache hmily participant.
*
* @param hmilyParticipant
* the hmily participant
*/
public void cacheHmilyParticipant(final HmilyParticipant hmilyParticipant) {
if (Objects.isNull(hmilyParticipant)) {
return;
}
HmilyParticipantCacheManager.getInstance().cacheHmilyParticipant(hmilyParticipant);
}
/**
* when nested transaction add participant.
*
* @param participantId
* key
* @param hmilyParticipant
* {@linkplain HmilyParticipant} | 3.26 |
hmily_HmilyTransactionHolder_getInstance_rdh | /**
* Gets instance.
*
* @return the instance
*/
public static HmilyTransactionHolder getInstance() {
return INSTANCE;
} | 3.26 |
hmily_HmilyTransactionHolder_remove_rdh | /**
* clean threadLocal help gc.
*/
public void remove() {
CURRENT.remove();
} | 3.26 |
hmily_HmilyTransactionHolder_registerStarterParticipant_rdh | /**
* add participant.
*
* @param hmilyParticipant
* {@linkplain HmilyParticipant}
*/
public void registerStarterParticipant(final HmilyParticipant hmilyParticipant) {
if (Objects.isNull(hmilyParticipant)) {
return;
}
Optional.ofNullable(getCurrentTransaction()).ifPresent(c -> c.registerParticipant(hmilyParticipant));
} | 3.26 |
hmily_CommonAssembler_assembleHmilySimpleTableSegment_rdh | /**
* Assemble hmily simple table segment.
*
* @param simpleTableSegment
* simple table segment
* @return hmily simple table segment
*/
public static HmilySimpleTableSegment assembleHmilySimpleTableSegment(final SimpleTableSegment simpleTableSegment) {
TableNameSegment tableNameSegment = simpleTableSegment.getTableName();
HmilyIdentifierValue hmilyIdentifierValue = new HmilyIdentifierValue(tableNameSegment.getIdentifier().getValue());
HmilyTableNameSegment hmilyTableNameSegment = new HmilyTableNameSegment(tableNameSegment.getStartIndex(), tableNameSegment.getStopIndex(), hmilyIdentifierValue);
HmilyOwnerSegment hmilyOwnerSegment
= null;
OwnerSegment ownerSegment;
if (simpleTableSegment.getOwner().isPresent()) {
ownerSegment = simpleTableSegment.getOwner().get();
hmilyOwnerSegment = new HmilyOwnerSegment(ownerSegment.getStartIndex(), ownerSegment.getStopIndex(), new HmilyIdentifierValue(ownerSegment.getIdentifier().getValue()));
}
HmilyAliasSegment hmilyAliasSegment = null;
String aliasSegmentString;
if (simpleTableSegment.getAlias().isPresent()) {
aliasSegmentString = simpleTableSegment.getAlias().get();
hmilyAliasSegment = new HmilyAliasSegment(0, 0, new HmilyIdentifierValue(aliasSegmentString));
}
HmilySimpleTableSegment
hmilySimpleTableSegment = new HmilySimpleTableSegment(hmilyTableNameSegment);
hmilySimpleTableSegment.setOwner(hmilyOwnerSegment);
hmilySimpleTableSegment.setAlias(hmilyAliasSegment);
return hmilySimpleTableSegment;
} | 3.26 |
hmily_CommonAssembler_assembleHmilyPaginationValueSegment_rdh | /**
* Assemble hmily PaginationValue segment.
*
* @param paginationValue
* pagination value segment
* @return Hmily pagination value segment
*/
public static HmilyPaginationValueSegment assembleHmilyPaginationValueSegment(final PaginationValueSegment paginationValue) {
HmilyPaginationValueSegment hmilyPaginationValueSegment = null;
int startIndex = paginationValue.getStartIndex();
int stopIndex = paginationValue.getStopIndex();
if (paginationValue instanceof NumberLiteralLimitValueSegment) {
hmilyPaginationValueSegment = new HmilyNumberLiteralLimitValueSegment(startIndex, stopIndex, ((NumberLiteralLimitValueSegment) (paginationValue)).getValue());
} else if (paginationValue instanceof ParameterMarkerLimitValueSegment) {
hmilyPaginationValueSegment = new HmilyParameterMarkerLimitValueSegment(startIndex, stopIndex, ((ParameterMarkerLimitValueSegment) (paginationValue)).getParameterIndex());
} else if (paginationValue instanceof NumberLiteralRowNumberValueSegment) {
NumberLiteralRowNumberValueSegment nrnvs = ((NumberLiteralRowNumberValueSegment) (paginationValue));
hmilyPaginationValueSegment = new HmilyNumberLiteralRowNumberValueSegment(startIndex, stopIndex, nrnvs.getValue(), nrnvs.isBoundOpened());
} else if (paginationValue instanceof ParameterMarkerRowNumberValueSegment) {
ParameterMarkerRowNumberValueSegment pmrnvs = ((ParameterMarkerRowNumberValueSegment) (paginationValue));
hmilyPaginationValueSegment = new HmilyParameterMarkerRowNumberValueSegment(startIndex, stopIndex, pmrnvs.getParameterIndex(), pmrnvs.isBoundOpened());
}
return hmilyPaginationValueSegment;
} | 3.26 |
hmily_CommonAssembler_assembleHmilyExpressionSegment_rdh | /**
* Assemble hmily expression segment.
*
* @param expression
* expression
* @return hmily expression segment
*/
public static HmilyExpressionSegment assembleHmilyExpressionSegment(final ExpressionSegment expression) {
HmilyExpressionSegment result = null;
if (expression instanceof BinaryOperationExpression) {
HmilyExpressionSegment hmilyLeft = assembleHmilyExpressionSegment(((BinaryOperationExpression) (expression)).getLeft());
HmilyExpressionSegment hmilyRight = assembleHmilyExpressionSegment(((BinaryOperationExpression) (expression)).getRight());
result = new HmilyBinaryOperationExpression(expression.getStartIndex(), expression.getStopIndex(), hmilyLeft, hmilyRight, ((BinaryOperationExpression) (expression)).getOperator(), ((BinaryOperationExpression) (expression)).getText());} else if (expression instanceof ColumnSegment) {
result = CommonAssembler.assembleHmilyColumnSegment(((ColumnSegment) (expression)));
} else if (expression instanceof CommonExpressionSegment) {
result = new HmilyCommonExpressionSegment(expression.getStartIndex(), expression.getStopIndex(), ((CommonExpressionSegment) (expression)).getText());
} else if (expression instanceof ExpressionProjectionSegment) {
result = new HmilyExpressionProjectionSegment(expression.getStartIndex(), expression.getStopIndex(), ((ExpressionProjectionSegment) (expression)).getText());
} else if (expression instanceof LiteralExpressionSegment) {
result = new HmilyLiteralExpressionSegment(expression.getStartIndex(), expression.getStopIndex(), ((LiteralExpressionSegment) (expression)).getLiterals());} else if (expression instanceof ParameterMarkerExpressionSegment) {
result = new HmilyParameterMarkerExpressionSegment(expression.getStartIndex(), expression.getStopIndex(), ((ParameterMarkerExpressionSegment) (expression)).getParameterMarkerIndex());
} else if ((expression instanceof InExpression) && (((InExpression) (expression)).getLeft() instanceof ColumnSegment)) {
// TODO
ColumnSegment column = ((ColumnSegment) (((InExpression) (expression)).getLeft()));
} else if ((expression instanceof BetweenExpression) && (((BetweenExpression) (expression)).getLeft() instanceof
ColumnSegment)) {
// TODO
ColumnSegment column = ((ColumnSegment) (((BetweenExpression) (expression)).getLeft()));
}
return result;
} | 3.26 |
hmily_CommonAssembler_assembleHmilyColumnSegment_rdh | /**
* Assemble hmily column segment.
*
* @param column
* column
* @return hmily column segment
*/public static HmilyColumnSegment assembleHmilyColumnSegment(final ColumnSegment column) {
HmilyIdentifierValue
hmilyIdentifierValue = new HmilyIdentifierValue(column.getIdentifier().getValue());
HmilyColumnSegment result = new HmilyColumnSegment(column.getStartIndex(), column.getStopIndex(), hmilyIdentifierValue);
column.getOwner().ifPresent(ownerSegment -> {
HmilyIdentifierValue identifierValue = new HmilyIdentifierValue(ownerSegment.getIdentifier().getValue());
result.setOwner(new HmilyOwnerSegment(ownerSegment.getStartIndex(), ownerSegment.getStopIndex(), identifierValue));});
return result;
} | 3.26 |
hmily_AbstractHmilyDatabase_executeUpdate_rdh | /**
* Execute update int.
*
* @param sql
* the sql
* @param params
* the params
* @return the int
*/
private int executeUpdate(final String sql, final Object... params) {
try (Connection con
= dataSource.getConnection();PreparedStatement ps = createPreparedStatement(con, sql, params)) {
return ps.executeUpdate();
} catch (SQLException e) {
log.error("hmily jdbc executeUpdate repository exception -> ", e);
return FAIL_ROWS;
}
} | 3.26 |
hmily_Resource_getResult_rdh | /**
* Gets result.
*
* @param r
* the r
* @return the result
*/
public static Result getResult(final int r) {
Result rs = READONLY;
switch (r) {
case 0 :
rs
= COMMIT;
break;
case 1 :
rs = ROLLBACK;
break;
case 2 :
rs = READONLY;
break;
default :
break;
}
return rs;} | 3.26 |
hmily_HmilyMySQLInsertStatement_getSetAssignment_rdh | /**
* Get set assignment segment.
*
* @return set assignment segment
*/
public Optional<HmilySetAssignmentSegment> getSetAssignment() {
return
Optional.ofNullable(setAssignment);
} | 3.26 |
hmily_RepositorySupportEnum_acquire_rdh | /**
* Acquire compensate cache type compensate cache type enum.
*
* @param support
* the compensate cache type
* @return the compensate cache type enum
*/
public static RepositorySupportEnum acquire(final String support) {
Optional<RepositorySupportEnum> repositorySupportEnum = Arrays.stream(RepositorySupportEnum.values()).filter(v -> Objects.equals(v.getSupport(), support)).findFirst();
return repositorySupportEnum.orElse(RepositorySupportEnum.MYSQL);
} | 3.26 |
hmily_AggregateBinder_binder_rdh | /**
* binder to AggregateBinder.
*
* @param target
* ta
* @param env
* the env
* @return aggregate binder
*/
static AggregateBinder<?> binder(final BindData<?> target, final Binder.Env env) {DataType type = target.getType();
// 如果map集合.
if (type.isMap()) {
return new MapBinder(env);
} else if (type.isCollection()) {
return new CollectionBinder(env);
} else if (type.isArray()) {
return new ArrayBinder(env);
}
return null;
} | 3.26 |
hmily_AggregateBinder_bind_rdh | /**
* Bind object.
*
* @param name
* the name
* @param target
* the target
* @param elementBinder
* the element binder
* @return the object
*/
@SuppressWarnings("unchecked")
public Object bind(final PropertyName name, final BindData<?> target, final AggregateElementBinder elementBinder) {
Object result = bind(name, target, getEnv(), elementBinder);
Supplier<?> targetValue = target.getValue();
if ((result == null) || (targetValue == null)) {
return result;
}
return merge(targetValue, ((T) (result)));
} | 3.26 |
hmily_AggregateBinder_wasSupplied_rdh | /**
* Was supplied boolean.
*
* @return the boolean
*/
public boolean wasSupplied() {
return this.supplied != null;
} | 3.26 |
hmily_AggregateBinder_getEnv_rdh | /**
* Gets env.
*
* @return the env
*/
Env getEnv() {
return env;
} | 3.26 |
hmily_GrpcHmilyClient_syncInvoke_rdh | /**
* grpc sync.
*
* @param <T>
* T
* @param clazz
* clazz
* @param abstractStub
* AbstractStub
* @param method
* String
* @param param
* Object
* @return t T
*/
public <T> T syncInvoke(final AbstractStub abstractStub, final String method, final Object param, final Class<T> clazz) {
GrpcHmilyContext.getHmilyFailContext().remove();GrpcHmilyContext.getHmilyClass().set(new GrpcInvokeContext(new Object[]{ abstractStub, method, param, clazz }));
if (SingletonHolder.INST.get(GrpcHmilyClient.class) == null) {
SingletonHolder.INST.register(GrpcHmilyClient.class, this);
}
for (Method m : abstractStub.getClass().getMethods()) {
if (m.getName().equals(method)) {
try
{
T res = ((T) (m.invoke(abstractStub, m.getParameterTypes()[0].cast(param))));
if (GrpcHmilyContext.getHmilyFailContext().get() != null) {
throw new HmilyRuntimeException();
}
return res;
} catch (Exception e) {
LOGGER.error("failed to invoke grpc server");
throw new HmilyRuntimeException();
}
}
}
return null;
} | 3.26 |
hmily_AbstractHmilyTransactionAspect_hmilyInterceptor_rdh | /**
* this is point cut with {@linkplain HmilyTCC}.
*/
@Pointcut("@annotation(org.dromara.hmily.annotation.HmilyTCC) || @annotation(org.dromara.hmily.annotation.HmilyTAC) || @annotation(org.dromara.hmily.annotation.HmilyXA)")
public void hmilyInterceptor() {
} | 3.26 |
hmily_AbstractHmilyTransactionAspect_interceptTccMethod_rdh | /**
* this is around in {@linkplain HmilyTCC}.
*
* @param proceedingJoinPoint
* proceedingJoinPoint
* @return Object object
* @throws Throwable
* Throwable
*/
@Around("hmilyInterceptor()")
public Object interceptTccMethod(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
return interceptor.invoke(proceedingJoinPoint);
} | 3.26 |
hmily_HmilyLoadBalanceUtils_doSelect_rdh | /**
* Do select referer.
*
* @param <T>
* the type parameter
* @param defaultReferer
* the default referer
* @param refererList
* the referer list
* @return the referer
*/
public static <T> Referer<T> doSelect(final Referer<T> defaultReferer, final List<Referer<T>> refererList) {
final HmilyTransactionContext hmilyTransactionContext = HmilyContextHolder.get();
if (Objects.isNull(hmilyTransactionContext)) {
return defaultReferer;
}
// if try
String v1 = defaultReferer.getInterface().getName();
if (hmilyTransactionContext.getAction() == HmilyActionEnum.TRYING.getCode()) {
URL_MAP.put(v1, defaultReferer.getUrl());
return defaultReferer;
}
final URL orlUrl = URL_MAP.get(v1);
URL_MAP.remove(v1);
if (Objects.nonNull(orlUrl)) {
for (Referer<T> inv : refererList) {if (Objects.equals(inv.getUrl(), orlUrl)) {
return inv;
}
}
}
return defaultReferer;
} | 3.26 |
hmily_QuoteCharacter_getQuoteCharacter_rdh | /**
* Get quote character.
*
* @param value
* value to be get quote character
* @return value of quote character
*/
public static QuoteCharacter 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_QuoteCharacter_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_HmilyAutoConfiguration_refererAnnotationBeanPostProcessor_rdh | /**
* Referer annotation bean post processor referer annotation bean post processor.
*
* @return the referer annotation bean post processor
*/
@Bean
@ConditionalOnProperty(value = "hmily.support.rpc.annotation", havingValue = "true")
public BeanPostProcessor refererAnnotationBeanPostProcessor() {
return new RefererAnnotationBeanPostProcessor();
} | 3.26 |
hmily_HmilyAutoConfiguration_hmilyTransactionAspect_rdh | /**
* HmilyAutoConfiguration is spring boot starter handler.
*
* @author xiaoyu(Myth)
*/
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true)public class HmilyAutoConfiguration {
/**
* Hmily transaction aspect spring boot hmily transaction aspect.
*
* @return the spring boot hmily transaction aspect
*/
@Bean
public SpringHmilyTransactionAspect hmilyTransactionAspect() {
return new SpringHmilyTransactionAspect();
} | 3.26 |
hmily_DateUtils_getDateYYYY_rdh | /**
* Gets date yyyy.
*
* @return the date yyyy
*/
public static Date getDateYYYY() {
LocalDateTime localDateTime = parseLocalDateTime(getCurrentDateTime());
ZoneId zone = ZoneId.systemDefault();
Instant v2 = localDateTime.atZone(zone).toInstant();
return Date.from(v2);
} | 3.26 |
hmily_DateUtils_parseLocalDateTime_rdh | /**
* parseLocalDateTime.
* out put format:yyyy-MM-dd HH:mm:ss
*
* @param str
* date String
* @return yyyy-MM-dd HH:mm:ss
* @see LocalDateTime
*/private static LocalDateTime parseLocalDateTime(final String str) {
return LocalDateTime.parse(str, DateTimeFormatter.ofPattern(DATE_FORMAT_DATETIME));
} | 3.26 |
hmily_InsertStatementAssembler_assembleHmilyInsertStatement_rdh | /**
* Assemble Hmily insert statement.
*
* @param insertStatement
* insert statement
* @param hmilyInsertStatement
* hmily insert statement
* @return hmily insert statement
*/
public static HmilyInsertStatement assembleHmilyInsertStatement(final InsertStatement insertStatement, final HmilyInsertStatement hmilyInsertStatement) {
HmilySimpleTableSegment v0 = CommonAssembler.assembleHmilySimpleTableSegment(insertStatement.getTable());
HmilyInsertColumnsSegment hmilyInsertColumnsSegment = null;
if (insertStatement.getInsertColumns().isPresent()) {
hmilyInsertColumnsSegment = assembleHmilyInsertColumnsSegment(insertStatement.getInsertColumns().get());}
Collection<HmilyInsertValuesSegment> hmilyInsertValuesSegments = assembleHmilyInsertValuesSegments(insertStatement.getValues());
hmilyInsertStatement.setTable(v0);
hmilyInsertStatement.setInsertColumns(hmilyInsertColumnsSegment);
for (HmilyInsertValuesSegment
each : hmilyInsertValuesSegments) {
hmilyInsertStatement.getValues().add(each);
}
return hmilyInsertStatement;
} | 3.26 |
hmily_HmilyLockCacheManager_get_rdh | /**
* Acquire hmily lock.
*
* @param lockId
* this guava key.
* @return {@linkplain HmilyTransaction}
*/
public Optional<HmilyLock> get(final String lockId) {
try {
return loadingCache.get(lockId);
} catch (ExecutionException ex) {
return Optional.empty();
}
} | 3.26 |
hmily_HmilyLockCacheManager_cacheHmilyLock_rdh | /**
* Cache hmily lock.
*
* @param lockId
* lock id
* @param hmilyLock
* the hmily lock
*/
public void cacheHmilyLock(final String lockId,
final HmilyLock hmilyLock) {
loadingCache.put(lockId, Optional.of(hmilyLock));
} | 3.26 |
hmily_HmilyLockCacheManager_removeByKey_rdh | /**
* remove guava cache by key.
*
* @param lockId
* guava cache key.
*/
public void removeByKey(final String lockId) {
if (Objects.nonNull(lockId)) {
loadingCache.invalidate(lockId);
}
} | 3.26 |
hmily_HmilyLockCacheManager_getInstance_rdh | /**
* Hmily lock cache manager.
*
* @return Hmily lock cache manager instance
*/
public static HmilyLockCacheManager getInstance() {
return
INSTANCE;
} | 3.26 |
hmily_YamlProcessor_setResources_rdh | /**
* Sets resources.
*
* @param resources
* the resources
*/
public void setResources(final InputStream... resources) {
this.resources = resources;
} | 3.26 |
hmily_YamlProcessor_process_rdh | /**
* Process.
*
* @param callback
* the callback
*/
protected void process(final MatchCallback callback) {
Yaml yaml = createYaml();for (InputStream resource : this.resources) {
boolean found = process(callback, yaml, resource);if ((this.resolutionMethod ==
ResolutionMethod.FIRST_FOUND) && found) {
return;
}
}
} | 3.26 |
hmily_YamlProcessor_getMostSpecific_rdh | /**
* The matcher should not be considered.
*/ABSTAIN;
/**
* Compare two {@link MatchStatus} items, returning the most specific status.
*
* @param a
* the a
* @param b
* the b
* @return the most specific
*/
public static MatchStatus
getMostSpecific(final MatchStatus a, final MatchStatus b) {
return a.ordinal() < b.ordinal() ? a : b;
} | 3.26 |
hmily_YamlProcessor_getFlattenedMap_rdh | /**
* Gets flattened map.
*
* @param source
* the source
* @return the flattened map
*/
protected final Map<String, Object> getFlattenedMap(final Map<String, Object> source) {Map<String, Object> result = new LinkedHashMap<>();
buildFlattenedMap(result, source, null);
return result;
} | 3.26 |
hmily_UpdateStatementAssembler_assembleHmilyUpdateStatement_rdh | /**
* Assemble Hmily update statement.
*
* @param updateStatement
* update statement
* @param hmilyUpdateStatement
* hmily update statement
* @return hmily update statement
*/
public static HmilyUpdateStatement assembleHmilyUpdateStatement(final UpdateStatement updateStatement, final HmilyUpdateStatement hmilyUpdateStatement) {
HmilySimpleTableSegment hmilySimpleTableSegment = CommonAssembler.assembleHmilySimpleTableSegment(((SimpleTableSegment) (updateStatement.getTableSegment())));
HmilySetAssignmentSegment hmilySetAssignmentSegment = assembleHmilySetAssignmentSegment(updateStatement.getSetAssignment());
HmilyWhereSegment hmilyWhereSegment = null;
if (updateStatement.getWhere().isPresent()) {hmilyWhereSegment = assembleHmilyWhereSegment(updateStatement.getWhere().get());
}
hmilyUpdateStatement.setTableSegment(hmilySimpleTableSegment);
hmilyUpdateStatement.setSetAssignment(hmilySetAssignmentSegment);
hmilyUpdateStatement.setWhere(hmilyWhereSegment);
return hmilyUpdateStatement;
} | 3.26 |
hmily_AbstractHmilySQLParserExecutor_generateHmilyInsertStatement_rdh | /**
* Generate Hmily insert statement.
*
* @param insertStatement
* insert statement
* @param hmilyInsertStatement
* hmily insert statement
* @return hmily insert statement
*/
public HmilyInsertStatement generateHmilyInsertStatement(final
InsertStatement insertStatement, final HmilyInsertStatement hmilyInsertStatement) {
return InsertStatementAssembler.assembleHmilyInsertStatement(insertStatement, hmilyInsertStatement);
} | 3.26 |
hmily_AbstractHmilySQLParserExecutor_generateHmilyDeleteStatement_rdh | /**
* Generate Hmily delete statement.
*
* @param deleteStatement
* delete statement
* @param hmilyDeleteStatement
* hmily delete statement
* @return hmily delete statement
*/
public HmilyDeleteStatement generateHmilyDeleteStatement(final DeleteStatement deleteStatement, final HmilyDeleteStatement hmilyDeleteStatement) {
return DeleteStatementAssembler.assembleHmilyDeleteStatement(deleteStatement, hmilyDeleteStatement);
} | 3.26 |
hmily_AbstractHmilySQLParserExecutor_generateHmilySelectStatement_rdh | /**
* Generate Hmily select statement.
*
* @param selectStatement
* select statement
* @param hmilySelectStatement
* hmily select statement
* @return hmily select statement
*/
public HmilySelectStatement generateHmilySelectStatement(final SelectStatement selectStatement, final HmilySelectStatement hmilySelectStatement) {
return SelectStatementAssembler.assembleHmilySelectStatement(selectStatement, hmilySelectStatement);
} | 3.26 |
hmily_AbstractHmilySQLParserExecutor_generateHmilyUpdateStatement_rdh | /**
* Generate Hmily update statement.
*
* @param updateStatement
* update statement
* @param hmilyUpdateStatement
* hmily update statement
* @return hmily update statement
*/
public HmilyUpdateStatement generateHmilyUpdateStatement(final UpdateStatement updateStatement, final HmilyUpdateStatement hmilyUpdateStatement) {
return UpdateStatementAssembler.assembleHmilyUpdateStatement(updateStatement, hmilyUpdateStatement);
} | 3.26 |
hmily_MotanHmilyAccountApplication_main_rdh | /**
* main.
*
* @param args
* args.
*/
public static void main(final String[] args) {
SpringApplication v0 = new SpringApplication(MotanHmilyAccountApplication.class);
v0.setWebApplicationType(WebApplicationType.NONE);
v0.run(args);
MotanSwitcherUtil.setSwitcherValue(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER, true);System.out.println("MotanHmilyAccountApplication server start...");
} | 3.26 |
hmily_XaLoadBalancerAutoConfiguration_xaLoadBalancerBeanPostProcessor_rdh | /**
* 注册 {@link XaLoadBalancerBeanPostProcessor} Bean.
*
* @return {@link XaLoadBalancerBeanPostProcessor} Bean
*/
@Bean
public static XaLoadBalancerBeanPostProcessor xaLoadBalancerBeanPostProcessor() {
return new XaLoadBalancerBeanPostProcessor();
} | 3.26 |
hmily_XaLoadBalancerAutoConfiguration_afterPropertiesSet_rdh | /**
* Ribbon基于{@link SpringClientFactory}来实现配置隔离,
* 要保证每种配置情况的{@link ILoadBalancer}都会被包装.
* 所以给{@link SpringClientFactory}添加一个默认config,它会注册{@link XaLoadBalancerBeanPostProcessor}.
*/
@Override
public void afterPropertiesSet() {
// default. 开头的是每个app context公用的默认的配置类
RibbonClientSpecification specification = new RibbonClientSpecification("default.SpringCloudXaBeanPostProcessor", new Class<?>[]{ XaLoadBalancerAutoConfiguration.Config.class });
f0.setConfigurations(Collections.singletonList(specification));
} | 3.26 |
hmily_XaLoadBalancerAutoConfiguration_xaTransactionEventListener_rdh | /**
* Register {@link SpringCloudXaLoadBalancer.TransactionEventListener} Bean.
*
* @return {@link SpringCloudXaLoadBalancer.TransactionEventListener} Bean
*/
@Bean
public TransactionEventListener xaTransactionEventListener() {
return new SpringCloudXaLoadBalancer.TransactionEventListener();
} | 3.26 |
hmily_HmilyRoundRobinLoadBalance_select_rdh | /**
* Use load balancing to select invoker.
*
* @param invokeContext
* invokeContext
* @return Invoker
* @throws NoInvokerException
* NoInvokerException
*/
@Override
public Invoker<T> select(final InvokeContext invokeContext) throws NoInvokerException {
List<Invoker<T>> staticWeightInvokers = staticWeightInvokersCache;
if ((staticWeightInvokers != null) && (!staticWeightInvokers.isEmpty())) {
Invoker<T>
invoker = staticWeightInvokers.get((staticWeightSequence.getAndIncrement() & Integer.MAX_VALUE) % staticWeightInvokers.size());
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;
}
}
List<Invoker<T>> sortedInvokers = sortedInvokersCache;
if (CollectionUtils.isEmpty(sortedInvokers)) {
throw new NoInvokerException("no such active connection invoker");}
List<Invoker<T>> list = new ArrayList<Invoker<T>>();
for (Invoker<T> invoker : sortedInvokers) {
if (!invoker.isAvailable())
{
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((sequence.getAndIncrement() & Integer.MAX_VALUE) % 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_HmilyRoundRobinLoadBalance_m0_rdh | /**
* Refresh local invoker.
*
* @param invokers
* invokers
*/
@Override
public void m0(final Collection<Invoker<T>> invokers) {
LOGGER.info("{} try to refresh RoundRobinLoadBalance's invoker cache, size= {} ", config.getSimpleObjectName(), CollectionUtils.isEmpty(invokers) ? 0 : invokers.size());
if (CollectionUtils.isEmpty(invokers)) {
sortedInvokersCache = null;staticWeightInvokersCache = null;
return;
}
final List<Invoker<T>> sortedInvokersTmp
= new ArrayList<Invoker<T>>(invokers);Collections.sort(sortedInvokersTmp, comparator);
sortedInvokersCache = sortedInvokersTmp;
staticWeightInvokersCache = LoadBalanceHelper.buildStaticWeightList(sortedInvokersTmp, config);LOGGER.info("{} refresh RoundRobinLoadBalance's invoker cache done, staticWeightInvokersCache size= {}, sortedInvokersCache size={}", config.getSimpleObjectName(), (staticWeightInvokersCache == null) || staticWeightInvokersCache.isEmpty() ? 0 : staticWeightInvokersCache.size(), (sortedInvokersCache == null) || sortedInvokersCache.isEmpty() ? 0 : sortedInvokersCache.size());
} | 3.26 |
hmily_HmilyXaException_getMessage_rdh | /**
* Gets message.
*
* @param xaException
* the xa exception
* @return the message
*/
public static String getMessage(final XAException xaException) {
int errorCode = xaException.errorCode;
String s = ERROR_CODES.get(errorCode);
return (("errorCode:" + errorCode) + ":") + s;} | 3.26 |
hmily_MotanHmilyInventoryApplication_main_rdh | /**
* main.
*
* @param args
* args.
*/
public static void main(final String[] args) {
SpringApplication springApplication = new SpringApplication(MotanHmilyInventoryApplication.class);
springApplication.setWebApplicationType(WebApplicationType.NONE);
springApplication.run(args);
MotanSwitcherUtil.setSwitcherValue(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER, true);
System.out.println("MotanHmilyInventoryApplication server start...");
} | 3.26 |
hmily_HmilyInExpression_getExpressionList_rdh | /**
* Get expression list from right.
*
* @return expression list.
*/
public Collection<HmilyExpressionSegment> getExpressionList() {
Collection<HmilyExpressionSegment> result = new LinkedList<>();
if (right instanceof HmilyListExpression) {
result.addAll(((HmilyListExpression) (right)).getItems());
} else {
result.add(this);
}
return result;
} | 3.26 |
hmily_OriginTrackedPropertiesLoader_getCharacter_rdh | /**
* Gets character.
*
* @return the character
*/
public char getCharacter() {
return ((char) (this.character));
} | 3.26 |
hmily_OriginTrackedPropertiesLoader_load_rdh | /**
* Load map.
*
* @param expandLists
* the expand lists
* @return the map
* @throws IOException
* the io exception
*/
public Map<String,
Object> load(final boolean expandLists) throws IOException {
try (CharacterReader reader = new CharacterReader(this.resource)) {
Map<String, Object> result = new LinkedHashMap<>();
StringBuilder buffer = new StringBuilder();while (reader.read()) {
String key = loadKey(buffer, reader).trim();
if (expandLists && key.endsWith("[]")) {
key = key.substring(0, key.length() - 2);
int index = 0;
do {
Object value = loadValue(buffer, reader, true);
put(result, ((key + "[") + (index++)) + "]", value);
if (!reader.isEndOfLine()) {
reader.read();
}
} while (!reader.isEndOfLine() );
} else {
Object value = loadValue(buffer, reader, false);
put(result, key, value);
}
}
return result;
}
} | 3.26 |
hmily_OriginTrackedPropertiesLoader_read_rdh | /**
* Read boolean.
*
* @param wrappedLine
* the wrapped line
* @return the boolean
* @throws IOException
* the io exception
*/
public boolean read(final boolean wrappedLine) throws IOException {
this.escaped = false;
this.character = this.reader.read();
this.columnNumber++;
if (this.columnNumber == 0) {
skipLeadingWhitespace();
if (!wrappedLine) {
skipComment();
}
}
if (this.character == '\\') {
this.escaped = true;
readEscaped();
} else if (this.character == '\n') {
this.columnNumber = -1;
}
return !isEndOfFile();
} | 3.26 |
hmily_OriginTrackedPropertiesLoader_isEndOfFile_rdh | /**
* Is end of file boolean.
*
* @return the boolean
*/
public boolean isEndOfFile() {
return this.character == (-1);
} | 3.26 |
hmily_OriginTrackedPropertiesLoader_isListDelimiter_rdh | /**
* Is list delimiter boolean.
*
* @return the boolean
*/
public boolean isListDelimiter() {
return (!this.escaped) && (this.character == ',');
} | 3.26 |
hmily_OriginTrackedPropertiesLoader_isEndOfLine_rdh | /**
* Is end of line boolean.
*
* @return the boolean
*/
public boolean
isEndOfLine() {
return (this.character == (-1)) || ((!this.escaped) && (this.character == '\n'));
} | 3.26 |
hmily_OriginTrackedPropertiesLoader_isWhiteSpace_rdh | /**
* Is white space boolean.
*
* @return the boolean
*/
public boolean isWhiteSpace() {
return (!this.escaped) && (((this.character == ' ') || (this.character == '\t')) || (this.character == '\f'));
} | 3.26 |
hmily_HmilyLogo_logo_rdh | /**
* Logo.
*/
public void logo() {
String bannerText = buildBannerText();
if (LOGGER.isInfoEnabled()) {
LOGGER.info(bannerText);
} else {
System.out.print(bannerText);
}
} | 3.26 |
hmily_HmilyContextHolder_set_rdh | /**
* Set.
*
* @param context
* the context
*/
public static void set(final HmilyTransactionContext context) {
hmilyContext.set(context);
} | 3.26 |
hmily_MapBinder_bindEntries_rdh | /**
* Bind entries.
*
* @param source
* the source
* @param map
* the map
*/void bindEntries(final ConfigPropertySource source, final Map<Object, Object> map) {
source.stream().forEach(name -> {
boolean ancestorOf = root.isAncestorOf(name);
if (ancestorOf) {BindData<?> valueBindData = getValueBindData(name);
PropertyName entryName = getEntryName(source, name);
Object key = getKeyName(entryName);
map.computeIfAbsent(key, k -> this.elementBinder.bind(entryName, valueBindData, this.env));
}
});
} | 3.26 |
hmily_HmilyTccTransactionExecutor_preTryParticipant_rdh | /**
* this is Participant transaction preTry.
*
* @param context
* transaction context.
* @param point
* cut point
* @return TccTransaction hmily transaction
*/
public HmilyParticipant preTryParticipant(final HmilyTransactionContext context, final ProceedingJoinPoint point) {
LogUtil.debug(LOGGER, "participant hmily tcc transaction start..:{}", context::toString);
final HmilyParticipant hmilyParticipant = buildHmilyParticipant(point, context.getParticipantId(), context.getParticipantRefId(), HmilyRoleEnum.PARTICIPANT.getCode(), context.getTransId());
HmilyTransactionHolder.getInstance().cacheHmilyParticipant(hmilyParticipant);
HmilyRepositoryStorage.createHmilyParticipant(hmilyParticipant);
// publishEvent
// Nested transaction support
context.setRole(HmilyRoleEnum.PARTICIPANT.getCode());
HmilyContextHolder.set(context);
return hmilyParticipant;
} | 3.26 |
hmily_HmilyTccTransactionExecutor_preTry_rdh | /**
* transaction preTry.
*
* @param point
* cut point.
* @return TccTransaction hmily transaction
*/
public HmilyTransaction preTry(final ProceedingJoinPoint point)
{LogUtil.debug(LOGGER, () -> "......hmily tcc transaction starter....");
// build tccTransaction
HmilyTransaction hmilyTransaction = createHmilyTransaction();
HmilyRepositoryStorage.createHmilyTransaction(hmilyTransaction);
HmilyParticipant hmilyParticipant = buildHmilyParticipant(point, null,
null, HmilyRoleEnum.START.getCode(), hmilyTransaction.getTransId());
HmilyRepositoryStorage.createHmilyParticipant(hmilyParticipant);
hmilyTransaction.registerParticipant(hmilyParticipant);
// save tccTransaction in threadLocal
HmilyTransactionHolder.getInstance().set(hmilyTransaction); // set TccTransactionContext this context transfer remote
HmilyTransactionContext context = new HmilyTransactionContext();
// set action is try
context.setAction(HmilyActionEnum.TRYING.getCode());
context.setTransId(hmilyTransaction.getTransId());
context.setRole(HmilyRoleEnum.START.getCode());
context.setTransType(TransTypeEnum.TCC.name());
HmilyContextHolder.set(context);
return hmilyTransaction;
} | 3.26 |
hmily_HmilyTccTransactionExecutor_participantConfirm_rdh | /**
* Participant confirm object.
*
* @param hmilyParticipantList
* the hmily participant list
* @param selfParticipantId
* the self participant id
* @return the object
*/
public Object participantConfirm(final List<HmilyParticipant> hmilyParticipantList, final Long selfParticipantId) {
if (CollectionUtils.isEmpty(hmilyParticipantList)) {
return null;
}
List<Object> results = Lists.newArrayListWithCapacity(hmilyParticipantList.size());
for (HmilyParticipant hmilyParticipant : hmilyParticipantList) {
try {if (hmilyParticipant.getParticipantId().equals(selfParticipantId)) {
final Object result = HmilyReflector.executor(HmilyActionEnum.CONFIRMING, ExecutorTypeEnum.LOCAL,
hmilyParticipant);
results.add(result);
HmilyRepositoryStorage.removeHmilyParticipant(hmilyParticipant);
} else {
final Object v10 = HmilyReflector.executor(HmilyActionEnum.CONFIRMING, ExecutorTypeEnum.RPC, hmilyParticipant);
results.add(v10);
}
} catch (Throwable throwable) {
throw new HmilyRuntimeException(" hmilyParticipant execute confirm exception:" + hmilyParticipant.toString());
} finally {
HmilyContextHolder.remove();
}
}
HmilyParticipantCacheManager.getInstance().removeByKey(selfParticipantId);
return results.get(0);
} | 3.26 |
hmily_HmilyTccTransactionExecutor_participantCancel_rdh | /**
* Participant cancel object.
*
* @param hmilyParticipants
* the hmily participants
* @param selfParticipantId
* the self participant id
* @return the object
*/
public Object participantCancel(final List<HmilyParticipant> hmilyParticipants, final Long selfParticipantId) {
LogUtil.debug(LOGGER, () -> "tcc cancel ...........start!");
if (CollectionUtils.isEmpty(hmilyParticipants)) {
return null;
}
// if cc pattern,can not execute cancel
// update cancel
HmilyParticipant selfHmilyParticipant = filterSelfHmilyParticipant(hmilyParticipants);
if (Objects.nonNull(selfHmilyParticipant)) {
selfHmilyParticipant.setStatus(HmilyActionEnum.CANCELING.getCode());
HmilyRepositoryStorage.updateHmilyParticipantStatus(selfHmilyParticipant);
}
List<Object> results = Lists.newArrayListWithCapacity(hmilyParticipants.size());
for (HmilyParticipant hmilyParticipant : hmilyParticipants) {
try {
if (hmilyParticipant.getParticipantId().equals(selfParticipantId)) {
final
Object result = HmilyReflector.executor(HmilyActionEnum.CANCELING, ExecutorTypeEnum.LOCAL, hmilyParticipant);
results.add(result);
HmilyRepositoryStorage.removeHmilyParticipant(hmilyParticipant);
} else {
final Object result = HmilyReflector.executor(HmilyActionEnum.CANCELING, ExecutorTypeEnum.RPC, hmilyParticipant);
results.add(result);
}
} catch (Throwable throwable) {
throw new HmilyRuntimeException(" hmilyParticipant execute cancel exception:"
+ hmilyParticipant.toString());
} finally {
HmilyContextHolder.remove();
}}
HmilyParticipantCacheManager.getInstance().removeByKey(selfParticipantId);
return results.get(0);
} | 3.26 |
hmily_HmilyTccTransactionExecutor_globalConfirm_rdh | /**
* Call the confirm method and basically if the initiator calls here call the remote or the original method
* However, the context sets the call confirm
* The remote service calls the confirm method.
*
* @param currentTransaction
* {@linkplain HmilyTransaction}
* @throws HmilyRuntimeException
* ex
*/
public void globalConfirm(final HmilyTransaction currentTransaction) throws HmilyRuntimeException {
LogUtil.debug(LOGGER, () -> "hmily transaction confirm .......!start");
if (Objects.isNull(currentTransaction) || CollectionUtils.isEmpty(currentTransaction.getHmilyParticipants())) {
return;
}
currentTransaction.setStatus(HmilyActionEnum.CONFIRMING.getCode());
HmilyRepositoryStorage.updateHmilyTransactionStatus(currentTransaction);
final List<HmilyParticipant> hmilyParticipants = currentTransaction.getHmilyParticipants();
List<Boolean> successList = new ArrayList<>();
for (HmilyParticipant
hmilyParticipant : hmilyParticipants) {
try {
if (hmilyParticipant.getRole() == HmilyRoleEnum.START.getCode()) {
HmilyReflector.executor(HmilyActionEnum.CONFIRMING, ExecutorTypeEnum.LOCAL, hmilyParticipant);
HmilyRepositoryStorage.removeHmilyParticipant(hmilyParticipant);
} else {
HmilyReflector.executor(HmilyActionEnum.CONFIRMING, ExecutorTypeEnum.RPC, hmilyParticipant);
}
successList.add(true);
} catch (Throwable e) {
successList.add(false);
LOGGER.error("HmilyParticipant confirm exception param:{} ", hmilyParticipant.toString(), e);
} finally {HmilyContextHolder.remove();
}
}
if (successList.stream().allMatch(e -> e)) {
// remove global
HmilyRepositoryStorage.removeHmilyTransaction(currentTransaction);
}
} | 3.26 |
hmily_HmilyTccTransactionExecutor_updateStartStatus_rdh | /**
* update transaction status by disruptor.
*
* @param hmilyTransaction
* {@linkplain HmilyTransaction}
*/
public void updateStartStatus(final HmilyTransaction hmilyTransaction) {
HmilyRepositoryStorage.updateHmilyTransactionStatus(hmilyTransaction);
HmilyParticipant hmilyParticipant = filterStartHmilyParticipant(hmilyTransaction);if (Objects.nonNull(hmilyParticipant)) {
hmilyParticipant.setStatus(hmilyTransaction.getStatus());
HmilyRepositoryStorage.updateHmilyParticipantStatus(hmilyParticipant);
}
} | 3.26 |
hmily_HmilyTccTransactionExecutor_globalCancel_rdh | /**
* cancel transaction.
*
* @param currentTransaction
* {@linkplain HmilyTransaction}
*/
public void globalCancel(final HmilyTransaction currentTransaction) {
LogUtil.debug(LOGGER, () -> "tcc cancel ...........start!");if (Objects.isNull(currentTransaction) || CollectionUtils.isEmpty(currentTransaction.getHmilyParticipants())) {
return;
}
currentTransaction.setStatus(HmilyActionEnum.CANCELING.getCode());
// update cancel
HmilyRepositoryStorage.updateHmilyTransactionStatus(currentTransaction);
final List<HmilyParticipant> hmilyParticipants = currentTransaction.getHmilyParticipants();
for (HmilyParticipant hmilyParticipant : hmilyParticipants) {
try {
if (hmilyParticipant.getRole() == HmilyRoleEnum.START.getCode()) {
HmilyReflector.executor(HmilyActionEnum.CANCELING, ExecutorTypeEnum.LOCAL, hmilyParticipant);
HmilyRepositoryStorage.removeHmilyParticipant(hmilyParticipant);
} else {
HmilyReflector.executor(HmilyActionEnum.CANCELING, ExecutorTypeEnum.RPC, hmilyParticipant);
}
} catch (Throwable e) {
LOGGER.error("HmilyParticipant cancel exception :{}", hmilyParticipant.toString(), e);
} finally {
HmilyContextHolder.remove();
}
}
} | 3.26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.