Search in sources :

Example 86 with StringSetMap

use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.

the class DbClientTest method testStringSetMap.

@Test
public void testStringSetMap() throws Exception {
    _logger.info("Starting StringSetMap test");
    DbClient dbClient = _dbClient;
    TenantOrg tenant = new TenantOrg();
    tenant.setId(URIUtil.createId(TenantOrg.class));
    StringSetMap sMap = new StringSetMap();
    tenant.setUserMappings(sMap);
    StringSet set = new StringSet();
    set.add("test1");
    sMap.put("key1", set);
    sMap.get("key1").add("test2");
    sMap.get("key1").remove("test1");
    dbClient.persistObject(tenant);
    // record pending
    tenant = dbClient.queryObject(TenantOrg.class, tenant.getId());
    sMap = tenant.getUserMappings();
    set = sMap.get("key1");
    Assert.assertEquals(set.size(), 1);
    Assert.assertEquals(set.contains("test2"), true);
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) DbClient(com.emc.storageos.db.client.DbClient) InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) StringSet(com.emc.storageos.db.client.model.StringSet) Test(org.junit.Test)

Example 87 with StringSetMap

use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.

the class DbClientTest method createTenants.

private List<TenantOrg> createTenants(int count, String label, String indexKey) {
    List<TenantOrg> tenants = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        TenantOrg t = new TenantOrg();
        t.setId(URIUtil.createId(TenantOrg.class));
        t.setLabel(label);
        t.setRoleAssignments(new StringSetMap());
        t.addRole(indexKey, "role1");
        t.addRole(indexKey, "role2");
        _dbClient.createObject(t);
        tenants.add(t);
    }
    return tenants;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) ArrayList(java.util.ArrayList) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 88 with StringSetMap

use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.

the class DbClientTest method testStringSetMapClear.

@Test
public void testStringSetMapClear() 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().clear();
    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());
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) DbClient(com.emc.storageos.db.client.DbClient) InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient) StringSet(com.emc.storageos.db.client.model.StringSet) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) Test(org.junit.Test)

Example 89 with StringSetMap

use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.

the class RemoteReplicationSet method addSystemRole.

public void addSystemRole(String systemName, String role) {
    if (this.systemToRolesMap == null) {
        this.systemToRolesMap = new StringSetMap();
    }
    if (this.systemToRolesMap.get(systemName) == null) {
        addSystemRolesEntry(systemName, new StringSet());
    }
    StringSet roles = this.systemToRolesMap.get(systemName);
    roles.add(role);
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 90 with StringSetMap

use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupUtils method getLocalSystemsInCG.

/**
 * Gets the storage system(s) containing the native CGs corresponding to the
 * passed VPLEX CG.
 *
 * @param cg A reference to a VPLEX CG
 * @param dbClient A reference to a database client
 *
 * @return A list of the the storage system(s) containing the native CGs
 *         corresponding to the passed VPLEX CG.
 */
public static List<URI> getLocalSystemsInCG(BlockConsistencyGroup cg, DbClient dbClient) {
    List<URI> localSystemUris = new ArrayList<URI>();
    StringSetMap systemCgMap = cg.getSystemConsistencyGroups();
    if (systemCgMap != null) {
        Iterator<String> cgSystemIdsIter = cg.getSystemConsistencyGroups().keySet().iterator();
        while (cgSystemIdsIter.hasNext()) {
            URI cgSystemUri = URI.create(cgSystemIdsIter.next());
            if (URIUtil.isType(cgSystemUri, StorageSystem.class)) {
                StorageSystem cgSystem = dbClient.queryObject(StorageSystem.class, cgSystemUri);
                // isBlockStorageSystem
                if (Type.isBlockStorageSystem(cgSystem.getSystemType())) {
                    localSystemUris.add(cgSystemUri);
                }
            }
        }
    }
    return localSystemUris;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ArrayList(java.util.ArrayList) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StringSetMap (com.emc.storageos.db.client.model.StringSetMap)158 StringSet (com.emc.storageos.db.client.model.StringSet)95 URI (java.net.URI)72 ArrayList (java.util.ArrayList)68 List (java.util.List)49 HashMap (java.util.HashMap)43 StoragePort (com.emc.storageos.db.client.model.StoragePort)37 Map (java.util.Map)32 Initiator (com.emc.storageos.db.client.model.Initiator)31 NamedURI (com.emc.storageos.db.client.model.NamedURI)31 StringMap (com.emc.storageos.db.client.model.StringMap)31 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)26 ExportMask (com.emc.storageos.db.client.model.ExportMask)25 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)25 HashSet (java.util.HashSet)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)21 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)18 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)17 Test (org.junit.Test)16