@Test public void publish() throws InterruptedException { TacInst abc = iMsInstService.getTacMsInst(1L); byte[] abcs = devMsInstFileService.getInstanceFile("abc"); Boolean publish = redisMsPublisher.publish(abc, abcs); assertTrue(publish); countDownLatch.await(); }
@Override public Boolean publish(TacInst tacInst, byte[] data) { byte[] instanceFile = data; tacInst.setJarVersion(TacFileService.getMd5(data)); tacInst.setStatus(TacInst.STATUS_PUBLISH); redisMsInstFileService.saveInstanceFile(tacInst, instanceFile); String msCode = tacInst.getMsCode(); TacMsPublishMeta publishMeta = new TacMsPublishMeta(tacInst); hashOperations.put(getMainKey(), msCode, publishMeta); redisTopicTemplate.convertAndSend(getPublishChannel(), JSONObject.toJSONString(publishMeta)); TacMsDO ms = msService.getMs(tacInst.getMsCode()); Long oldPublishId = ms.getPublishedInstId(); ms.setPublishedInstId(tacInst.getId()); msService.updateMs(tacInst.getMsCode(), ms); msInstService.updateTacMsInst(tacInst.getId(), tacInst); if (oldPublishId != null && !oldPublishId.equals(tacInst.getId())) { TacInst tacMsInst = msInstService.getTacMsInst(oldPublishId); if (tacMsInst != null) { tacMsInst.setStatus(TacInst.STATUS_PRE_PUBLISH); msInstService.updateTacMsInst(oldPublishId, tacMsInst); } } return true; }
RedisMsPublisher extends AbstractDefaultMsPublisher { @Override public Boolean publish(TacInst tacInst, byte[] data) { byte[] instanceFile = data; tacInst.setJarVersion(TacFileService.getMd5(data)); tacInst.setStatus(TacInst.STATUS_PUBLISH); redisMsInstFileService.saveInstanceFile(tacInst, instanceFile); String msCode = tacInst.getMsCode(); TacMsPublishMeta publishMeta = new TacMsPublishMeta(tacInst); hashOperations.put(getMainKey(), msCode, publishMeta); redisTopicTemplate.convertAndSend(getPublishChannel(), JSONObject.toJSONString(publishMeta)); TacMsDO ms = msService.getMs(tacInst.getMsCode()); Long oldPublishId = ms.getPublishedInstId(); ms.setPublishedInstId(tacInst.getId()); msService.updateMs(tacInst.getMsCode(), ms); msInstService.updateTacMsInst(tacInst.getId(), tacInst); if (oldPublishId != null && !oldPublishId.equals(tacInst.getId())) { TacInst tacMsInst = msInstService.getTacMsInst(oldPublishId); if (tacMsInst != null) { tacMsInst.setStatus(TacInst.STATUS_PRE_PUBLISH); msInstService.updateTacMsInst(oldPublishId, tacMsInst); } } return true; } }
RedisMsPublisher extends AbstractDefaultMsPublisher { @Override public Boolean publish(TacInst tacInst, byte[] data) { byte[] instanceFile = data; tacInst.setJarVersion(TacFileService.getMd5(data)); tacInst.setStatus(TacInst.STATUS_PUBLISH); redisMsInstFileService.saveInstanceFile(tacInst, instanceFile); String msCode = tacInst.getMsCode(); TacMsPublishMeta publishMeta = new TacMsPublishMeta(tacInst); hashOperations.put(getMainKey(), msCode, publishMeta); redisTopicTemplate.convertAndSend(getPublishChannel(), JSONObject.toJSONString(publishMeta)); TacMsDO ms = msService.getMs(tacInst.getMsCode()); Long oldPublishId = ms.getPublishedInstId(); ms.setPublishedInstId(tacInst.getId()); msService.updateMs(tacInst.getMsCode(), ms); msInstService.updateTacMsInst(tacInst.getId(), tacInst); if (oldPublishId != null && !oldPublishId.equals(tacInst.getId())) { TacInst tacMsInst = msInstService.getTacMsInst(oldPublishId); if (tacMsInst != null) { tacMsInst.setStatus(TacInst.STATUS_PRE_PUBLISH); msInstService.updateTacMsInst(oldPublishId, tacMsInst); } } return true; }  }
RedisMsPublisher extends AbstractDefaultMsPublisher { @Override public Boolean publish(TacInst tacInst, byte[] data) { byte[] instanceFile = data; tacInst.setJarVersion(TacFileService.getMd5(data)); tacInst.setStatus(TacInst.STATUS_PUBLISH); redisMsInstFileService.saveInstanceFile(tacInst, instanceFile); String msCode = tacInst.getMsCode(); TacMsPublishMeta publishMeta = new TacMsPublishMeta(tacInst); hashOperations.put(getMainKey(), msCode, publishMeta); redisTopicTemplate.convertAndSend(getPublishChannel(), JSONObject.toJSONString(publishMeta)); TacMsDO ms = msService.getMs(tacInst.getMsCode()); Long oldPublishId = ms.getPublishedInstId(); ms.setPublishedInstId(tacInst.getId()); msService.updateMs(tacInst.getMsCode(), ms); msInstService.updateTacMsInst(tacInst.getId(), tacInst); if (oldPublishId != null && !oldPublishId.equals(tacInst.getId())) { TacInst tacMsInst = msInstService.getTacMsInst(oldPublishId); if (tacMsInst != null) { tacMsInst.setStatus(TacInst.STATUS_PRE_PUBLISH); msInstService.updateTacMsInst(oldPublishId, tacMsInst); } } return true; }  @Override Boolean publish(TacInst tacInst, byte[] data); @Override Boolean offline(TacInst tacInst); @Override Boolean prePublish(TacInst tacInst, byte[] data); @Override TacInst gitPrePublish(TacMsDO tacMsDO, TacInst tacInst); }
RedisMsPublisher extends AbstractDefaultMsPublisher { @Override public Boolean publish(TacInst tacInst, byte[] data) { byte[] instanceFile = data; tacInst.setJarVersion(TacFileService.getMd5(data)); tacInst.setStatus(TacInst.STATUS_PUBLISH); redisMsInstFileService.saveInstanceFile(tacInst, instanceFile); String msCode = tacInst.getMsCode(); TacMsPublishMeta publishMeta = new TacMsPublishMeta(tacInst); hashOperations.put(getMainKey(), msCode, publishMeta); redisTopicTemplate.convertAndSend(getPublishChannel(), JSONObject.toJSONString(publishMeta)); TacMsDO ms = msService.getMs(tacInst.getMsCode()); Long oldPublishId = ms.getPublishedInstId(); ms.setPublishedInstId(tacInst.getId()); msService.updateMs(tacInst.getMsCode(), ms); msInstService.updateTacMsInst(tacInst.getId(), tacInst); if (oldPublishId != null && !oldPublishId.equals(tacInst.getId())) { TacInst tacMsInst = msInstService.getTacMsInst(oldPublishId); if (tacMsInst != null) { tacMsInst.setStatus(TacInst.STATUS_PRE_PUBLISH); msInstService.updateTacMsInst(oldPublishId, tacMsInst); } } return true; }  @Override Boolean publish(TacInst tacInst, byte[] data); @Override Boolean offline(TacInst tacInst); @Override Boolean prePublish(TacInst tacInst, byte[] data); @Override TacInst gitPrePublish(TacMsDO tacMsDO, TacInst tacInst);  }