Skip to content

Commit 5c8bedb

Browse files
Merge pull request #68 from yuriy-glotanov/2025.1
RELEASE 2025.1
2 parents 97d6a97 + cc5b8cf commit 5c8bedb

29 files changed

+612
-192
lines changed

src/main/java/su/interference/core/Instance.java

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,17 @@ public DataFile[] getDataFiles() {
532532
return res.toArray(new DataFile[]{});
533533
}
534534

535+
public Map<Integer, DataFile> getDataFilesMap() {
536+
final Map<Integer, DataFile> res = new HashMap<>();
537+
for (Object o : tDataFile.getIndexFieldByColumn("fileId").getIndex().getContent()) {
538+
res.put(((DataFile)((DataChunk)o).getEntity()).getFileId(), (DataFile)((DataChunk)o).getEntity());
539+
}
540+
return res;
541+
}
542+
535543
public MgmtModule[] getMgmtModules() {
536544
final Table t = getTableByName("su.interference.persistent.MgmtModule");
537-
final ArrayList<MgmtModule> res = new ArrayList<MgmtModule>();
545+
final ArrayList<MgmtModule> res = new ArrayList<>();
538546
for (Object o : t.getIndexFieldByColumn("moduleId").getIndex().getContent()) {
539547
res.add((MgmtModule)((DataChunk)o).getEntity());
540548
}
@@ -551,6 +559,15 @@ public synchronized Cursor getCursorById (long id) {
551559
return (Cursor)((DataChunk)t.getIndexFieldByColumn("cursorId").getIndex().getObjectByKey(id)).getEntity();
552560
}
553561

562+
public synchronized List<Cursor> getCursors () {
563+
final Table t = getTableByName("su.interference.persistent.Cursor");
564+
final ArrayList<Cursor> res = new ArrayList<>();
565+
for (Object o : t.getIndexFieldByColumn("cursorId").getIndex().getContent()) {
566+
res.add((Cursor)((DataChunk)o).getEntity());
567+
}
568+
return res;
569+
}
570+
554571
public Table getTableById (int id) {
555572
if (tt != null) {
556573
final MapField map = tt.getMapFieldByColumn("objectId");
@@ -564,6 +581,22 @@ public Table getTableById (int id) {
564581
return null;
565582
}
566583

584+
public List<Table> getTables () {
585+
final List<Table> result = new ArrayList<>();
586+
if (tt != null) {
587+
final MapField map = tt.getMapFieldByColumn("objectId");
588+
if (map != null) {
589+
for (Object o : map.getMap().entrySet()) {
590+
final DataChunk c = (DataChunk) ((Map.Entry) o).getValue();
591+
if (c != null) {
592+
result.add((Table) c.getEntity());
593+
}
594+
}
595+
}
596+
}
597+
return result;
598+
}
599+
567600
public synchronized Table getTableByName (String name) {
568601
final MapField map = tt.getMapFieldByColumn("name");
569602
if (map != null && name != null) {
@@ -584,6 +617,22 @@ public Map getFramesMap () {
584617
return ixf.getMap();
585618
}
586619

620+
public List<FrameData> getSortedDataFrames (Map<Integer, DataFile> dfsmap, int type) {
621+
final MapField ixf = tFrameData.getMapFieldByColumn("frameId");
622+
final ArrayList<FrameData> r = new ArrayList<>();
623+
//ixf.getMap().values().stream().map(o -> ((DataChunk) o).getEntity()).filter(o -> dfsmap.get(((FrameData) o).getAllocFile()).getType() == type).sorted().forEach(o -> r.add((FrameData) o));
624+
for (Object o : ixf.getMap().values()) {
625+
FrameData fd = (FrameData) ((DataChunk) o).getEntity();
626+
int fileId = (int) fd.getFile();
627+
System.out.println(fileId);
628+
if (dfsmap.get(fileId).getType() == type) {
629+
r.add(fd);
630+
}
631+
}
632+
Collections.sort(r);
633+
return r;
634+
}
635+
587636
public FrameData getFrameById (long id) {
588637
final MapField ixf = tFrameData.getMapFieldByColumn("frameId");
589638
final Map ixl = ixf.getMap();
@@ -638,6 +687,19 @@ public ArrayList<DataFile> getDataFilesByType (int id) {
638687
return r;
639688
}
640689

690+
public synchronized List<Session> getSessions () {
691+
List<Session> res = new ArrayList<>();
692+
if (Instance.getInstance().systemState==Instance.SYSTEM_STATE_UP) {
693+
Table t = getTableByName("su.interference.persistent.Session");
694+
for (Object o : t.getIndexFieldByColumn("sessionId").getIndex().getContent()) {
695+
res.add((Session) ((DataChunk) o).getEntity());
696+
}
697+
} else {
698+
res.add(Session.getDntmSession());
699+
}
700+
return res;
701+
}
702+
641703
public synchronized Session getSession (String sessionId) {
642704
if (sessionId == null) {
643705
return null;
@@ -701,14 +763,19 @@ public ArrayList<FrameSync> getSyncFrames(int nodeId) {
701763
return r;
702764
}
703765

766+
public synchronized Process getProcessById (int id) {
767+
final Table t = getTableByName("su.interference.persistent.Process");
768+
return (Process)((DataChunk)t.getIndexFieldByColumn("processId").getIndex().getObjectByKey(id)).getEntity();
769+
}
770+
704771
public synchronized Process getProcessByName (String name) {
705772
final Table t = getTableByName("su.interference.persistent.Process");
706773
return (Process)((DataChunk)t.getIndexFieldByColumn("processName").getIndex().getObjectByKey(name)).getEntity();
707774
}
708775

709776
public synchronized List<Process> getProcesses () {
710777
final Table t = getTableByName("su.interference.persistent.Process");
711-
final ArrayList<Process> r = new ArrayList<Process>();
778+
final ArrayList<Process> r = new ArrayList<>();
712779
for (Object o : t.getIndexFieldByColumn("processId").getIndex().getContent()) {
713780
r.add((Process)((DataChunk)o).getEntity());
714781
}

src/main/java/su/interference/mgmt/MgmtAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2019 interference
4+
Copyright (c) 2010-2025 interference
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2010-2025 interference
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
*/
24+
25+
package su.interference.mgmt;
26+
27+
import java.lang.annotation.Retention;
28+
import java.lang.annotation.RetentionPolicy;
29+
30+
/**
31+
* @author Yuriy Glotanov
32+
* @since 1.0
33+
*/
34+
35+
@Retention(RetentionPolicy.RUNTIME)
36+
public @interface MgmtClass {
37+
38+
}

src/main/java/su/interference/mgmt/MgmtClassIdColumn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2019 interference
4+
Copyright (c) 2010-2025 interference
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in

src/main/java/su/interference/mgmt/MgmtColumn.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2019 interference
4+
Copyright (c) 2010-2025 interference
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -34,8 +34,6 @@ this software and associated documentation files (the "Software"), to deal in
3434

3535
@Retention(RetentionPolicy.RUNTIME)
3636
public @interface MgmtColumn {
37+
String name();
3738
int width();
38-
boolean show();
39-
boolean form();
40-
boolean edit();
4139
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/**
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2010-2025 interference
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
*/
24+
25+
package su.interference.mgmt;
26+
27+
import java.lang.reflect.Field;
28+
import java.lang.reflect.InvocationTargetException;
29+
import java.lang.reflect.Method;
30+
31+
/**
32+
* @author Yuriy Glotanov
33+
* @since 1.0
34+
*/
35+
36+
public class MgmtContainer {
37+
MgmtColumn mgmtColumn;
38+
MgmtAction mgmtAction;
39+
Field field;
40+
Method method;
41+
Class c;
42+
Field idField;
43+
44+
public MgmtContainer(MgmtColumn mgmtColumn, MgmtAction mgmtAction, Field field, Method method, Class c, Field idField) {
45+
this.mgmtColumn = mgmtColumn;
46+
this.mgmtAction = mgmtAction;
47+
this.field = field;
48+
this.method = method;
49+
this.c = c;
50+
this.idField = idField;
51+
}
52+
53+
public MgmtColumn getMgmtColumn() {
54+
return mgmtColumn;
55+
}
56+
57+
public MgmtAction getMgmtAction() {
58+
return mgmtAction;
59+
}
60+
61+
public Field getField() {
62+
return field;
63+
}
64+
65+
public Method getMethod() {
66+
return method;
67+
}
68+
69+
public int getSize() {
70+
if (mgmtColumn != null) {
71+
return mgmtColumn.width();
72+
} else {
73+
return 10;
74+
}
75+
}
76+
77+
public String getHeader() {
78+
if (mgmtColumn != null) {
79+
return mgmtColumn.name();
80+
} else {
81+
return "";
82+
}
83+
}
84+
85+
public String getValue(Object o) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
86+
if (this.mgmtColumn == null || this.field == null) {
87+
return null;
88+
} else {
89+
String getName = "get" + this.field.getName().substring(0,1).toUpperCase() + this.field.getName().substring(1);
90+
Method m = this.c.getMethod(getName, null);
91+
Object result = m.invoke(o, null);
92+
return String.valueOf(result);
93+
}
94+
}
95+
96+
public String getId(Object o) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
97+
if (this.idField == null) {
98+
return null;
99+
} else {
100+
String getName = "get" + this.idField.getName().substring(0,1).toUpperCase() + this.idField.getName().substring(1);
101+
Method m = this.c.getMethod(getName, null);
102+
Object result = m.invoke(o, null);
103+
return String.valueOf(result);
104+
}
105+
}
106+
107+
public boolean isCommand() {
108+
return this.method != null && this.mgmtAction != null;
109+
}
110+
}

src/main/java/su/interference/persistent/Cursor.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2021 head systems, ltd
4+
Copyright (c) 2010-2025 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -26,6 +26,7 @@ this software and associated documentation files (the "Software"), to deal in
2626

2727
import su.interference.core.*;
2828
import su.interference.exception.InternalException;
29+
import su.interference.mgmt.MgmtClass;
2930
import su.interference.mgmt.MgmtColumn;
3031
import su.interference.sql.SQLSelect;
3132

@@ -42,6 +43,7 @@ this software and associated documentation files (the "Software"), to deal in
4243
@Entity
4344
@SystemEntity
4445
@DisableSync
46+
@MgmtClass
4547
public class Cursor implements Serializable {
4648
@Transient
4749
public static final int MASTER_TYPE = 1;
@@ -65,25 +67,25 @@ public class Cursor implements Serializable {
6567
@IndexColumn
6668
@GeneratedValue
6769
@DistributedId
68-
@MgmtColumn(width=10, show=true, form=false, edit=false)
70+
@MgmtColumn(name="Cursor Id",width=10)
6971
private long cursorId;
7072
@Column
71-
@MgmtColumn(width=10, show=true, form=false, edit=false)
73+
@MgmtColumn(name="SQL",width=50)
7274
private String sql;
7375
@Column
74-
@MgmtColumn(width=10, show=true, form=false, edit=false)
76+
@MgmtColumn(name="Target Node",width=10)
7577
private int targetNodeId;
7678
@Column
77-
@MgmtColumn(width=10, show=true, form=false, edit=false)
79+
@MgmtColumn(name="Target Id",width=10)
7880
private int targetId;
7981
@Column
80-
@MgmtColumn(width=10, show=true, form=false, edit=false)
82+
@MgmtColumn(name="Target Class",width=10)
8183
private String targetClassName;
8284
@Column
83-
@MgmtColumn(width=10, show=true, form=false, edit=false)
85+
@MgmtColumn(name="Type",width=10)
8486
private int type;
8587
@Column
86-
@MgmtColumn(width=10, show=true, form=false, edit=false)
88+
@MgmtColumn(name="State",width=10)
8789
private int state;
8890

8991
@Transient

0 commit comments

Comments
 (0)