use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class DbClientTest method testStringSetMapReplace.
@Test
public void testStringSetMapReplace() throws Exception {
// shows behavior of AbstractChangeTrackingMapSet.clear()
_logger.info("Starting StringSetMapReplace test");
DbClient dbClient = _dbClient;
ProtectionSystem ps = new ProtectionSystem();
ps.setId(URIUtil.createId(ProtectionSystem.class));
StringSet set1 = new StringSet();
set1.add("test1");
set1.add("test2");
set1.add("test3");
set1.add("test4");
StringSet set2 = new StringSet();
set2.add("test5");
set2.add("test6");
set2.add("test7");
set2.add("test8");
String key1 = "key1";
String key2 = "key2";
StringSetMap sMap = new StringSetMap();
sMap.put(key1, set1);
sMap.put(key2, set2);
ps.setSiteInitiators(sMap);
dbClient.createObject(ps);
ProtectionSystem ps1 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
StringSet set3 = new StringSet();
set3.add("test9");
set3.add("test10");
set3.add("test11");
set3.add("test12");
StringSet set4 = new StringSet();
set4.add("test13");
set4.add("test14");
set4.add("test15");
set4.add("test16");
String key4 = "key4";
String key3 = "key3";
StringSetMap sMap2 = new StringSetMap();
sMap2.put(key3, set3);
sMap2.put(key4, set4);
ps1.getSiteInitiators().replace(sMap2);
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key1));
Assert.assertTrue(ps1.getSiteInitiators().get(key1).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps1.getSiteInitiators().get(key2).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps1.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps1.getSiteInitiators().get(key4).isEmpty());
dbClient.persistObject(ps1);
ProtectionSystem ps2 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key1));
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps2.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps2.getSiteInitiators().get(key4).isEmpty());
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class DbClientTest method testStringSetMapRemove.
@Test
public void testStringSetMapRemove() throws Exception {
// shows behavior of AbstractChangeTrackingMapSet.clear()
_logger.info("Starting StringSetMap3 test");
DbClient dbClient = _dbClient;
ProtectionSystem ps = new ProtectionSystem();
ps.setId(URIUtil.createId(ProtectionSystem.class));
StringSet set1 = new StringSet();
set1.add("test1");
set1.add("test2");
set1.add("test3");
set1.add("test4");
StringSet set2 = new StringSet();
set2.add("test5");
set2.add("test6");
set2.add("test7");
set2.add("test8");
String key1 = "key1";
String key2 = "key2";
StringSetMap sMap = new StringSetMap();
sMap.put(key1, set1);
sMap.put(key2, set2);
ps.setSiteInitiators(sMap);
dbClient.createObject(ps);
ProtectionSystem ps1 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
StringSet set3 = new StringSet();
set3.add("test9");
set3.add("test10");
set3.add("test11");
set3.add("test12");
StringSet set4 = new StringSet();
set4.add("test13");
set4.add("test14");
set4.add("test15");
set4.add("test16");
String key4 = "key4";
String key3 = "key3";
StringSetMap sMap2 = new StringSetMap();
sMap2.put(key3, set3);
sMap2.put(key4, set4);
ps1.getSiteInitiators().remove(key1);
ps1.getSiteInitiators().remove(key2);
ps1.getSiteInitiators().putAll(sMap2);
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key1));
Assert.assertTrue(ps1.getSiteInitiators().get(key1).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps1.getSiteInitiators().get(key2).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps1.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps1.getSiteInitiators().get(key4).isEmpty());
dbClient.persistObject(ps1);
ProtectionSystem ps2 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key1));
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps2.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps2.getSiteInitiators().get(key4).isEmpty());
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class DbInitiatorHostMigrationTest method createExportMask.
private ExportMask createExportMask(List<Initiator> initiators) {
StringSet initiatorIds = new StringSet();
for (Initiator initiator : initiators) {
initiatorIds.add(initiator.getId().toString());
}
StringMap userAdded = new StringMap();
for (Initiator initiator : initiators) {
userAdded.put(initiator.getInitiatorPort().replaceAll(":", ""), initiator.getId().toString());
}
StringSetMap zoningMap = new StringSetMap();
StoragePort port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
StringSet portMap = new StringSet();
portMap.add(port.getId().toString());
zoningMap.put(initiators.get(0).getId().toString(), portMap);
ExportMask mask = new ExportMask();
mask.setId(URIUtil.createId(ExportMask.class));
mask.setInitiators(initiatorIds);
mask.setUserAddedInitiators(userAdded);
mask.setZoningMap(zoningMap);
_dbClient.createObject(mask);
return mask;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class VDCRoleMigrationCallback method process.
@Override
public void process() throws MigrationCallbackException {
_log.info("VDC Role Migration Started ...");
DbClient dbClient = getDbClient();
TenantOrg rootTenant = findRootTenant(dbClient);
StringSetMap tenantRoles = rootTenant.getRoleAssignments();
if (tenantRoles == null) {
_log.info("No Role Assignments in original Root Tenant. Skip moving.");
return;
}
VirtualDataCenter vdc = VdcUtil.getLocalVdc();
if (vdc == null) {
throw new IllegalStateException("the CF of Local VDC is not found.");
}
// only copy VDC role assignments
copyRoleAssignments(tenantRoles, vdc);
removeRoleFromRootTenant(vdc, rootTenant);
dbClient.persistObject(vdc);
dbClient.persistObject(rootTenant);
_log.info("VDC Role Migration Done.");
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ExportMaskUtils method getZoneMapFromZoneInfoMap.
/**
* Given zoneInfoMap stored in an UnManagedExportMask, create a zone map for the
* initiators in the list.
*
* @param zoneInfoMap zoneInfoMap stored from a UnManagedExportMask
* @param initiators a list of initiators for which the zone map should created
* @return a zone map of initiator-uri-to-list-of-ports-uris
*/
public static StringSetMap getZoneMapFromZoneInfoMap(ZoneInfoMap zoneInfoMap, List<Initiator> initiators) {
StringSetMap zoneMap = new StringSetMap();
if (zoneInfoMap != null && initiators != null) {
for (Initiator initiator : initiators) {
for (ZoneInfo info : zoneInfoMap.values()) {
if (info.getInitiatorId().equals(initiator.getId().toString())) {
zoneMap.put(initiator.getId().toString(), info.getPortId());
}
}
}
}
_log.info("getZoneMapFromZoneInfoMap created zone map {}", zoneMap);
return zoneMap;
}
Aggregations