use of com.creditease.uav.helpers.uuid.IdWorker in project uavstack by uavorg.
the class ConfigurationManager method initNodeUUID.
private void initNodeUUID(String metadatafolder) {
String idFile = metadatafolder + "/" + this.profileName + ".uuid";
this.nodeUUID = IOHelper.readTxtFile(idFile, "utf-8");
if (null == this.nodeUUID) {
// read datacenter id, yes THINK BIG
String datacenterid = this.getConfiguration("meta.datacenterid");
if (null == datacenterid) {
datacenterid = "1";
}
IdWorker idWorker = CommonHelper.getUUIDWorker(new Random().nextInt(30) + 1, Integer.parseInt(datacenterid));
this.nodeUUID = String.valueOf(idWorker.nextId());
try {
IOHelper.writeTxtFile(idFile, this.nodeUUID, "utf-8", false);
} catch (IOException e) {
throw new RuntimeException("Write UUID to file \"" + idFile + "\" Fails.", e);
}
}
}
use of com.creditease.uav.helpers.uuid.IdWorker in project uavstack by uavorg.
the class GodEyeRestService method saveFeedback.
// ---------------------------------------新日志服务接口 END-------------------------------------
// ---------------------------------------反馈建议 START-----------------------------------
/**
* searchNewLog
*
* @param data
* @param resp
*/
@SuppressWarnings("unchecked")
@POST
@Path("/feedback/save")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void saveFeedback(String reqData, @Suspended AsyncResponse resp) {
String userId = "";
if (null != request.getSession(false)) {
Object obj = request.getSession(false).getAttribute("apphub.gui.session.login.user.id");
userId = null == obj ? "" : String.valueOf(obj);
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String time = simpleDateFormat.format(new Date());
Map<String, String> httpData = JSONHelper.toObject(reqData, Map.class);
httpData.put("time", time);
httpData.put("uid", userId);
IdWorker idWorker = CommonHelper.getUUIDWorker(new Random().nextInt(30) + 1, 1);
String uuid = String.valueOf(idWorker.nextId());
httpData.put("key", uuid);
/**
* 打包请求数据
*/
Map<String, Object> mapParam = new HashMap<String, Object>();
mapParam.put("type", "create");
mapParam.put("data", httpData);
UAVHttpMessage request = new UAVHttpMessage();
request.putRequest("mrd.data", JSONHelper.toString(mapParam));
request.putRequest("datastore.name", "AppHub.feedback");
request.putRequest("mgo.coll.name", "uav_feedback");
doHttpPost("uav.app.manage.apphubmanager.http.addr", "/ah/feedback", request, new GodEyeCB(resp));
}
Aggregations