public static void syncNodes(DbConn cnx, List<NodeDto> dtos) { for (NodeDto existing : getNodes(cnx)) { boolean foundInNewSet = false; for (NodeDto newdto : dtos) { if (newdto.getId() != null && newdto.getId().equals(existing.getId())) { foundInNewSet = true; break; } } if (!foundInNewSet) { deleteQueue(cnx, existing.getId()); } } for (NodeDto dto : dtos) { upsertNode(cnx, dto); } }
public static void syncNodes(DbConn cnx, List<NodeDto> dtos) { for (NodeDto existing : getNodes(cnx)) { boolean foundInNewSet = false; for (NodeDto newdto : dtos) { if (newdto.getId() != null && newdto.getId().equals(existing.getId())) { foundInNewSet = true; break; } } if (!foundInNewSet) { deleteQueue(cnx, existing.getId()); } } for (NodeDto dto : dtos) { upsertNode(cnx, dto); } }
target.setRootLogLevel(template.getRootLogLevel()); target.setTmpDirectory(template.getTmpDirectory()); MetaService.upsertNode(cnx, target);
target.setRootLogLevel(template.getRootLogLevel()); target.setTmpDirectory(template.getTmpDirectory()); MetaService.upsertNode(cnx, target);
@Test public void testTemplate() throws Exception { NodeDto template = MetaService.getNode(cnx, TestHelpers.nodeMix.getId()); template.setPort(123); MetaService.upsertNode(cnx, template); cnx.commit(); NodeDto target = MetaService.getNode(cnx, TestHelpers.node.getId()); Assert.assertEquals(3, MetaService.getNodeQueueMappings(cnx, target.getId()).size()); // Capital letter -> should be ignored. Main.runCommand(new String[] { "Install-NodeTemPlate", "-t", TestHelpers.nodeMix.getName(), "-n", TestHelpers.node.getName() }); target = MetaService.getNode(cnx, TestHelpers.node.getId()); Assert.assertEquals(template.getPort(), target.getPort()); Assert.assertEquals(1, MetaService.getNodeQueueMappings(cnx, target.getId()).size()); } }