Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions src/main/java/su/interference/core/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ this software and associated documentation files (the "Software"), to deal in

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import su.interference.mgmt.MgmtConfig;

import java.util.ArrayList;
import java.util.Properties;
import java.util.*;
import java.io.FileInputStream;
import java.io.File;
import java.io.IOException;
import java.util.StringTokenizer;

/**
* @author Yuriy Glotanov
Expand Down Expand Up @@ -460,4 +459,46 @@ private static int validatePercent(String value, String description, int def) {
return def;
}

public Map<String, Object> getSystemParameters() {
Map<String, Object> result = new HashMap<>();
result.put(P_LOCAL_NODE_ID, LOCAL_NODE_ID);
result.put(P_DB_PATH, DB_PATH);
result.put(JOURNAL_PATH, JOURNAL_PATH);
result.put(P_CLUSTER_NODES, CLUSTER_NODES);
result.put(P_REGISTER_CLASSES, REGISTER_CLASSES);
result.put(P_MMPORT, MMPORT);
result.put(P_RMPORT, RMPORT);
result.put(P_FRAMESIZE, FRAMESIZE);
result.put(P_FRAMESIZE2, FRAMESIZE2);
result.put(P_FILES_AMOUNT, FILES_AMOUNT);
result.put(P_DISKIO_MODE, DISKIO_MODE);
result.put(P_SYNC_LOCK_ENABLE, SYNC_LOCK_ENABLE);
result.put(P_SYNC_PERIOD, SYNC_PERIOD);
result.put(P_RETRIEVE_QUEUE_SIZE, RETRIEVE_QUEUE_SIZE);
result.put(P_RETRIEVE_THREADS_AMOUNT, RETRIEVE_THREADS_AMOUNT);
result.put(P_CODEPAGE, CODEPAGE);
result.put(P_DATEFORMAT, DATEFORMAT);
result.put(P_REMOTE_SYNC_TIMEOUT, REMOTE_SYNC_TIMEOUT);
result.put(P_READ_BUFFER_SIZE, READ_BUFFER_SIZE);
result.put(P_WRITE_BUFFER_SIZE, WRITE_BUFFER_SIZE);
result.put(P_TRANS_CLEANUP_TIMEOUT, TRANS_CLEANUP_TIMEOUT);
result.put(P_CLEANUP_ENABLE, CLEANUP_ENABLE);
result.put(P_CLEANUP_TIMEOUT, CLEANUP_TIMEOUT);
result.put(P_CLEANUP_PROTECTION_THR, CLEANUP_PROTECTION_THR);
result.put(P_IX_CLEANUP_PROTECTION_THR, IX_CLEANUP_PROTECTION_THR);
result.put(P_HEAP_USE_THR_DATA, HEAP_USE_THR_DATA);
result.put(P_HEAP_USE_THR_INDX, HEAP_USE_THR_INDX);
result.put(P_HEAP_USE_THR_TEMP, HEAP_USE_THR_TEMP);
result.put(P_HEAP_USE_THR_UNDO, HEAP_USE_THR_UNDO);
return result;
}

public List<MgmtConfig> getMgmtConfigParams() {
List<MgmtConfig> result = new ArrayList<>();
for (Map.Entry<String, Object> entry : getSystemParameters().entrySet()) {
result.add(new MgmtConfig(entry.getKey(), entry.getValue()));
}
return result;
}

}
25 changes: 25 additions & 0 deletions src/main/java/su/interference/core/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,31 @@ public FreeFrame getFreeFrameById (long id) {
return (FreeFrame)dc.getEntity();
}

public int getFreeFramesCount (int fileId) {
final IndexList ixf = tFreeFrame.getIndexFieldByColumn("frameId").getIndex();
int result = 0;
for (Object o : ixf.getContent()) {
final DataChunk dc = (DataChunk) o;
if (((FreeFrame) dc.getEntity()).getFile() == fileId) {
result++;
}
}
return result;
}

public int getFramesCount (int fileId) {
final MapField ixf = tFrameData.getMapFieldByColumn("frameId");
final Map ixl = ixf.getMap();
int result = 0;
for (Object o : ixl.values()) {
final DataChunk dc = (DataChunk) o;
if (((FrameData) dc.getEntity()).getFile() == fileId) {
result++;
}
}
return result;
}

public ArrayList<FrameSync> getSyncFrames(int nodeId) {
final ArrayList<FrameSync> r = new ArrayList<>();
String uuid = null;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/su/interference/core/SyncQueue.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
The MIT License (MIT)

Copyright (c) 2010-2021 head systems, ltd
Copyright (c) 2010-2025 head systems, ltd

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -140,6 +140,7 @@ public void commit() throws Exception {
}

public void run () {
this.f = true;
Thread.currentThread().setName("interference-sync-thread-"+Thread.currentThread().getId());
while (f) {
latch = new CountDownLatch(1);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/su/interference/core/SystemCleanUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class SystemCleanUp implements Runnable, ManagedProcess {
public static final int INDEX_RETRIEVED_PRIORITY = 9;

public void run () {
this.f = true;
Thread.currentThread().setName("interference-cleanup-thread-"+Thread.currentThread().getId());
while (f) {
latch = new CountDownLatch(1);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/su/interference/core/TransCleanUp.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
The MIT License (MIT)

Copyright (c) 2010-2021 head systems, ltd
Copyright (c) 2010-2025 head systems, ltd

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -44,6 +44,7 @@ public class TransCleanUp implements Runnable, ManagedProcess {
private final static Logger logger = LoggerFactory.getLogger(TransCleanUp.class);

public void run () {
this.f = true;
Thread.currentThread().setName("interference-transactions-cleanup-thread-"+Thread.currentThread().getId());
while (f) {
latch = new CountDownLatch(1);
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/su/interference/mgmt/MgmtConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
The MIT License (MIT)

Copyright (c) 2010-2025 interference

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/

package su.interference.mgmt;

/**
* @author Yuriy Glotanov
* @since 1.0
*/

@MgmtClass
public class MgmtConfig {
@MgmtColumn(name="Configuration parameter",width=20)
private final String confParam;
@MgmtColumn(name="Parameter Value",width=80)
private final Object confValue;

public MgmtConfig(String confParam, Object confValue) {
this.confParam = confParam;
this.confValue = confValue;
}

public String getConfParam() {
return confParam;
}

public String getConfValue() {
if (confValue instanceof String[]) {
return String.join("<br>", ((String[]) confValue));
} else {
return String.valueOf(confValue);
}
}
}
5 changes: 5 additions & 0 deletions src/main/java/su/interference/persistent/Cursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ this software and associated documentation files (the "Software"), to deal in
import su.interference.exception.InternalException;
import su.interference.mgmt.MgmtClass;
import su.interference.mgmt.MgmtColumn;
import su.interference.sql.SQLCursor;
import su.interference.sql.SQLSelect;

import javax.persistence.*;
Expand Down Expand Up @@ -221,4 +222,8 @@ public boolean isStream() {
return this.type == STREAM_TYPE;
}

public List<SQLCursor> getSQLCursors() {
return this.getSqlStmt().getSQLCursors();
}

}
37 changes: 33 additions & 4 deletions src/main/java/su/interference/persistent/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ this software and associated documentation files (the "Software"), to deal in
import java.lang.reflect.InvocationTargetException;
import javax.persistence.*;

import static su.interference.core.Storage.*;

/**
* @author Yuriy Glotanov
* @since 1.0
Expand All @@ -59,7 +61,6 @@ public class DataFile implements Serializable {
private int fileId;
@Column
@IndexColumn
@MgmtColumn(name="Type",width=10)
private int type;
@Column
@IndexColumn
Expand All @@ -69,14 +70,21 @@ public class DataFile implements Serializable {
@MgmtColumn(name="Name",width=70)
private String fileName;
@Column
@MgmtColumn(name="Size",width=10)
private long fileSize;
@Column
@MgmtColumn(name="Used",width=10)
private long fileUsed;
@Column
private int fileExtAmount;
@MgmtColumn(name="Frames allocated",width=20)
@Transient
private int framesCnt;
@MgmtColumn(name="Frames deallocated",width=20)
@Transient
private int freeFramesCnt;

@MgmtColumn(name="Type",width=20)
@Transient
private String dataFileType;
@Transient
public static final int CLASS_ID = 4;
@Transient
Expand Down Expand Up @@ -523,7 +531,7 @@ public void writeFrame(FrameData bd, final long ptr, final byte[] b, LLT llt, Se
}

public boolean isData() {
return this.type == Storage.DATAFILE_TYPEID;
return this.type == DATAFILE_TYPEID;
}

public boolean isIndex() {
Expand Down Expand Up @@ -590,4 +598,25 @@ public void setFileExtAmount(int fileExtAmount) {
this.fileExtAmount = fileExtAmount;
}

public int getFramesCnt() {
return Instance.getInstance().getFramesCount(this.fileId);
}

public int getFreeFramesCnt() {
return Instance.getInstance().getFreeFramesCount(this.fileId);
}

public String getDataFileType() {
switch (this.type) {
case DATAFILE_TYPEID:
return "DATA";
case INDXFILE_TYPEID:
return "INDEX";
case UNDOFILE_TYPEID:
return "UNDO";
case TEMPFILE_TYPEID:
return "TEMP";
}
return "N/A";
}
}
3 changes: 1 addition & 2 deletions src/main/java/su/interference/persistent/Process.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public void start (Runnable r, Session s) {
this.ro = r;
this.th = new Thread(r);
this.th.start();
Thread.State ts = this.th.getState();
this.state = ts.name();
this.state = "STARTED";
try {
s.persist(this); //update
} catch (Exception e) {
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/su/interference/persistent/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public class Transaction implements Serializable {
@MgmtColumn(name="Timestamp",width=10)
private long timeStamp;
@Column
@MgmtColumn(name="Transaction type",width=10)
private int transType; // 0 - READ COMMITTED, 1 - SERIALIZABLE, 9 - THR
@Column
@MgmtColumn(name="MTRAN",width=10)
Expand All @@ -84,6 +83,9 @@ public class Transaction implements Serializable {
@MgmtColumn(name="Commit Id",width=10)
private long cid;

@MgmtColumn(name="Transaction type",width=20)
@Transient
private String transactionType;
@Transient
private final transient List<TransFrame> tframes = new CopyOnWriteArrayList<>();
@Transient
Expand Down Expand Up @@ -781,4 +783,18 @@ public SQLJoin getJoin() {
public void setJoin(SQLJoin join) {
this.join = join;
}

public String getTransactionType() {
switch (this.transType) {
case TRAN_READ_COMMITTED:
return "READ COMMITTED";
case TRAN_SERIALIZABLE:
return "SERIALIZABLE";
case TRAN_THR:
return "COMPLETED";
case TRAN_LEGACY:
return "COMPLETED";
}
return "N/A";
}
}
5 changes: 5 additions & 0 deletions src/main/java/su/interference/rest/HTTPSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ public void run() {
sbuf.append(pbuf, 0, read);
read = in.read(pbuf);
}
StringBuffer sbuf2 = new StringBuffer();
while (read >= 0 && !(sbuf2.lastIndexOf("\r\n") == sbuf2.length())) {
sbuf2.append(pbuf, 0, read);
read = in.read(pbuf);
}
parseParams(sbuf.toString().trim(), params);
}

Expand Down
Loading