-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPatchCase.java
More file actions
35 lines (32 loc) · 1.27 KB
/
Copy pathPatchCase.java
File metadata and controls
35 lines (32 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.io.*;
import java.util.*;
public class PatchCase {
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
File f = new File("data/c.dat");
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
Map<Long, Object> cases = (Map<Long, Object>) ois.readObject();
ois.close();
boolean changed = false;
for (Map.Entry<Long, Object> e : cases.entrySet()) {
Object c = e.getValue();
java.lang.reflect.Field f2 = c.getClass().getDeclaredField("solrSourceCore");
f2.setAccessible(true);
String current = (String) f2.get(c);
System.out.println("Case id=" + e.getKey() + " solrSourceCore=" + current);
if (!"shmcloud_2".equals(current)) {
f2.set(c, "shmcloud_2");
System.out.println(" -> fixed to shmcloud_2");
changed = true;
}
}
if (changed) {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
oos.writeObject(cases);
oos.close();
System.out.println("Saved.");
} else {
System.out.println("All cores already correct.");
}
}
}