Project

General

Profile

« Previous | Next » 

Revision 7790

Added by Jing Tao almost 11 years ago

Add method to get identifier set.

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/DistributedMapsFactory.java
42 42
import com.hazelcast.config.Config;
43 43
import com.hazelcast.config.FileSystemXmlConfig;
44 44
import com.hazelcast.core.IMap;
45
import com.hazelcast.core.ISet;
45 46

  
46 47

  
47 48
/**
......
51 52
 */
52 53
public class DistributedMapsFactory {
53 54
    
55
    private static final String IDENTIFIERSETNAME = "hzIdentifiers";
54 56
    private static Log log = LogFactory.getLog(DistributedMapsFactory.class);
55 57
    
56 58
    private static HazelcastClient hzClient = null;
......
60 62
    private static int maxAttempts = IndexGenerator.MAXWAITNUMBER;
61 63
    private static IMap<Identifier, SystemMetadata> systemMetadataMap = null;
62 64
    private static IMap<Identifier, String> objectPathMap = null;
65
    /* The name of the identifiers set */
66
    private static String identifiersSetName = IDENTIFIERSETNAME;
67
    /* The Hazelcast distributed identifiers set */
68
    private static ISet<Identifier> identifiersSet = null;
63 69
    
64 70
    /*
65 71
     * Start the hazel cast client
......
74 80
            waitingTime = IndexGenerator.WAITTIME;
75 81
            maxAttempts = IndexGenerator.MAXWAITNUMBER;
76 82
        }
83
        try {
84
            identifiersSetName = Settings.getConfiguration().getString("dataone.hazelcast.storageCluster.identifiersSet");
85
        } catch (Exception e) {
86
            log.warn("DistributedMapFactory.startHazelCastClient - couldn't read the name of the identifiersSet from the metacat.properties file since : "+e.getMessage()+". Default values will be used");
87
            identifiersSetName = IDENTIFIERSETNAME;
88
        }
77 89
     // get config values
78 90
        hzSystemMetadata = Settings.getConfiguration().getString(
79 91
                "dataone.hazelcast.storageCluster.systemMetadataMap");
......
205 217
        return data;
206 218
    }
207 219
    
220
    /**
221
     * Get the identifiers set in the hazelcast client. The null may be returned if we can't find the set.
222
     * @return the identifiersSet
223
     * @throws FileNotFoundException
224
     * @throws ServiceFailure
225
     */
226
    public static ISet getIdentifiersSet() throws FileNotFoundException, ServiceFailure {
227
        if(hzClient== null) {
228
            startHazelCastClient();
229
        }
230
        identifiersSet= hzClient.getSet(identifiersSetName);
231
        return identifiersSet;
232
    }
233
    
208 234
}

Also available in: Unified diff