Project

General

Profile

« Previous | Next » 

Revision 6424

Added by rnahf over 12 years ago

configuring hazelcast tests

View differences:

ObjectPathMap.java
38 38
	private static IdentifierManager im;
39 39
	private static String dataPath;
40 40
	private static String metadataPath;
41
	
42
	private static boolean hasDataStore;
41 43

  
42 44

  
43 45
	
44 46
	/**
45
	 * creates an ObjectPathMapLoader
47
	 * creates an ObjectPathMap
46 48
	 */
47 49
	public ObjectPathMap() {
48 50
//		try {
......
59 61
		dataPath = "/data/";
60 62
		metadataPath = "/metadata/";
61 63
		im = IdentifierManager.getInstance();
64
		String role = System.getProperties().getProperty("hazelcast.hzObjectPathRole");
65
		if (role != null && role.equals("consumer")) {
66
			hasDataStore = false;
67
			System.out.println("new instance of ObjectPathMap: role = " + role);
68
		} else {
69
			hasDataStore = true;
70
			System.out.println("new instance of ObjectPathMap: role = " + role);
71
		}
62 72
	}
63 73

  
64 74
	
......
69 79
	 */
70 80
	private String pathToDocid(String localid) throws McdbDocNotFoundException  {
71 81
		
72
		Hashtable<String, Object> ht = im.getDocumentInfo(localid);
73
		if (ht.get("doctype").equals("BIN")) {
74
			return dataPath + FileUtil.getFS() + localid;
75
		} else {
76
			return metadataPath + FileUtil.getFS() + localid;
77
		}		
82
		return "/some/path/" + localid; 
83
//		Hashtable<String, Object> ht = im.getDocumentInfo(localid);
84
//		if (ht.get("doctype").equals("BIN")) {
85
//			return dataPath + FileUtil.getFS() + localid;
86
//		} else {
87
//			return metadataPath + FileUtil.getFS() + localid;
88
//		}		
78 89
	}
79 90

  
80 91
	
......
87 98
	@Override
88 99
	public String load(Identifier key) 
89 100
	{
90
		String docid = null;
91
		String path = null;
92
		try {
93
			docid = im.getLocalId(key.getValue());
94
			path = pathToDocid(docid);
95
		} catch (McdbDocNotFoundException e) {
96
			// TODO Auto-generated catch block
97
			e.printStackTrace();
101
		if (hasDataStore) {
102
			String docid = null;
103
			String path = null;
104
//			try {
105
//				docid = im.getLocalId(key.getValue());
106
//				path = pathToDocid(docid);			
107
//			} catch (McdbDocNotFoundException e) {
108
//				// TODO Auto-generated catch block
109
//				e.printStackTrace();
110
//				return null;
111
//			}
112
			path = "/path/" + key.getValue();
113
			return path;
114
		} else {
98 115
			return null;
99 116
		}
100
		return path;
101 117
	}
102 118
	
103 119
	
......
109 125
	@Override
110 126
	public Map<Identifier, String> loadAll(Collection<Identifier> identifiers) {
111 127
		
112
		Hashtable<Identifier,String> map = new Hashtable<Identifier,String>();
113
		for (Identifier id : identifiers) {
114
			try {
115
				String docid = im.getLocalId(id.getValue());
116
				map.put(id, pathToDocid(docid));
117
				
118
			} catch (McdbDocNotFoundException e) {
119
				// TODO should the map load an empty path instead of
120
				// leaving out the entire entry?
121
				e.printStackTrace();
128
		if (hasDataStore) {
129
			Hashtable<Identifier,String> map = new Hashtable<Identifier,String>();
130
			for (Identifier id : identifiers) {
131
				map.put(id, "/path/" + id.getValue());
132
//				try {
133
//					String docid = im.getLocalId(id.getValue());
134
//					map.put(id, pathToDocid(docid));
135
//
136
//				} catch (McdbDocNotFoundException e) {
137
//					// TODO should the map load an empty path instead of
138
//					// leaving out the entire entry?
139
//					e.printStackTrace();
140
//				}
122 141
			}
142
			return map;
143
		} else {
144
			return null;
123 145
		}
124
		return map;
125 146
	}
126 147

  
127 148
	
......
134 155
	 */
135 156
	@Override
136 157
	public Set<Identifier> loadAllKeys() {
137
		
138
		List<String> guids = im.getAllGUIDs();
139
		
140
		Set<Identifier> set = Collections.synchronizedSet(new HashSet<Identifier>());
141
		for (String guid : guids) {
142
			Identifier id = new Identifier();
143
			id.setValue(guid);
144
			set.add(id);
158

  
159
		if (hasDataStore) {
160
			//		List<String> guids = im.getAllGUIDs();
161
			//		
162
			Set<Identifier> set = Collections.synchronizedSet(new HashSet<Identifier>());
163
			//		for (String guid : guids) {
164
			//			Identifier id = new Identifier();
165
			//			id.setValue(guid);
166
			//			set.add(id);
167
			//		}
168

  
169
			for (int i=1; i< 100; i++) {
170
				Identifier id = new Identifier();
171
				id.setValue("testID." + i);
172
				set.add(id);
173
			}
174
			return set;
175
		} else {
176
			return null;
145 177
		}
146
		return set;
147 178
	}
148 179
}

Also available in: Unified diff