Search in sources :

Example 1 with DalEventEnum

use of com.ctrip.platform.dal.dao.DalEventEnum in project dal by ctripcorp.

the class SmartReadRouteStrategy method locateDbShard.

@Override
public String locateDbShard(DalConfigure configure, String logicDbName, DalHints hints) {
    String shard = null;
    DalEventEnum operation = (DalEventEnum) hints.get(DalHintEnum.operation);
    DatabaseSet dbSet = configure.getDatabaseSet(logicDbName);
    if (operation == DalEventEnum.QUERY) {
        Integer lastUpdateTime = dbTimeoutMap.get(logicDbName);
        // No update from server started
        if (lastUpdateTime == null) {
        //				return dbSet.getSlaveDbs(dbSet.getAllShards().iterator().next());
        }
    } else {
    }
    //		return (Set<String>)hints.get(DalHintEnum.shards);
    return null;
}
Also used : DalEventEnum(com.ctrip.platform.dal.dao.DalEventEnum) DatabaseSet(com.ctrip.platform.dal.dao.configure.DatabaseSet)

Example 2 with DalEventEnum

use of com.ctrip.platform.dal.dao.DalEventEnum in project dal by ctripcorp.

the class LoggerHelper method getParams.

public static String getParams(LogEntry entry) {
    DalEventEnum event = entry.getEvent();
    String[] pramemters = entry.getPramemters();
    StringBuilder sbout = new StringBuilder();
    if (pramemters == null || pramemters.length <= 0) {
        return sbout.toString();
    }
    if (event == DalEventEnum.QUERY || event == DalEventEnum.UPDATE_SIMPLE || event == DalEventEnum.UPDATE_KH || event == DalEventEnum.CALL) {
        return null != pramemters && pramemters.length > 0 ? pramemters[0] : "";
    }
    if (event == DalEventEnum.BATCH_UPDATE_PARAM || event == DalEventEnum.BATCH_CALL) {
        for (String param : pramemters) {
            sbout.append(param + ";");
        }
        return sbout.substring(0, sbout.length() - 1);
    }
    return "";
}
Also used : DalEventEnum(com.ctrip.platform.dal.dao.DalEventEnum)

Aggregations

DalEventEnum (com.ctrip.platform.dal.dao.DalEventEnum)2 DatabaseSet (com.ctrip.platform.dal.dao.configure.DatabaseSet)1