Skip to content

Commit ca3dd49

Browse files
authored
Issue #835対応 (#836)
Co-authored-by: m-takata <[email protected]>
1 parent b60ef0d commit ca3dd49

8 files changed

+359
-125
lines changed

src/main/java/jp/ossc/nimbus/service/context/DistributedSharedContextService.java

+12
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,18 @@ public void putAsynch(Object key, Object value) throws SharedContextSendExceptio
15231523
selectDistributeContext(key).putAsynch(key, value);
15241524
}
15251525

1526+
public Object getUpdateTemplate(Object key) throws SharedContextSendException{
1527+
return getUpdateTemplate(key, defaultTimeout);
1528+
}
1529+
1530+
public Object getUpdateTemplate(Object key, long timeout) throws SharedContextSendException, SharedContextTimeoutException{
1531+
return getUpdateTemplate(key, timeout, false);
1532+
}
1533+
1534+
public Object getUpdateTemplate(Object key, long timeout, boolean withTransaction) throws SharedContextSendException, SharedContextTimeoutException{
1535+
return selectDistributeContext(key).getUpdateTemplate(key, timeout, withTransaction);
1536+
}
1537+
15261538
public void update(Object key, SharedContextValueDifference diff) throws SharedContextSendException{
15271539
update(key, diff, defaultTimeout);
15281540
}

src/main/java/jp/ossc/nimbus/service/context/SharedContext.java

+32
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,38 @@ public interface SharedContext extends Context{
222222
*/
223223
public void putAsynch(Object key, Object value) throws SharedContextSendException;
224224

225+
/**
226+
* 指定したキーの値を差分更新するためのテンプレートとなるオブジェクトを取得する。<p>
227+
*
228+
* @param key キー
229+
* @return 差分更新するためのテンプレートとなるオブジェクト
230+
* @exception SharedContextSendException 分散サーバへのメッセージ送信に失敗した場合
231+
*/
232+
public Object getUpdateTemplate(Object key) throws SharedContextSendException;
233+
234+
/**
235+
* 指定したキーの値を差分更新するためのテンプレートとなるオブジェクトを取得する。<p>
236+
*
237+
* @param key キー
238+
* @param timeout タイムアウト[ms]
239+
* @return 差分更新するためのテンプレートとなるオブジェクト
240+
* @exception SharedContextSendException 分散サーバへのメッセージ送信に失敗した場合
241+
* @exception SharedContextTimeoutException 分散サーバからの応答待ちでタイムアウトした場合
242+
*/
243+
public Object getUpdateTemplate(Object key, long timeout) throws SharedContextSendException, SharedContextTimeoutException;
244+
245+
/**
246+
* 指定したキーの値を差分更新するためのテンプレートとなるオブジェクトを取得する。<p>
247+
*
248+
* @param key キー
249+
* @param timeout タイムアウト[ms]
250+
* @param withTransaction trueの場合、トランザクションを考慮する
251+
* @return 差分更新するためのテンプレートとなるオブジェクト
252+
* @exception SharedContextSendException 分散サーバへのメッセージ送信に失敗した場合
253+
* @exception SharedContextTimeoutException 分散サーバからの応答待ちでタイムアウトした場合
254+
*/
255+
public Object getUpdateTemplate(Object key, long timeout, boolean withTransaction) throws SharedContextSendException, SharedContextTimeoutException;
256+
225257
/**
226258
* 指定したキーで、指定した差分を更新する。<p>
227259
*

src/main/java/jp/ossc/nimbus/service/context/SharedContextRecord.java

+6
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ public int getUpdateVersion(){
101101
return updateVersion;
102102
}
103103

104+
public Object getUpdateTemplate(){
105+
SharedContextRecord clone = (SharedContextRecord)cloneSchema();
106+
clone.updateVersion = updateVersion;
107+
return clone;
108+
}
109+
104110
protected static int compareToUpdateVersion(int ver1, int ver2){
105111
long version1 = ver1;
106112
long version2 = ver2;

src/main/java/jp/ossc/nimbus/service/context/SharedContextRecordList.java

+21
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ public int getUpdateVersion(){
175175
return updateVersion;
176176
}
177177

178+
public Object getUpdateTemplate(){
179+
SharedContextRecordList clone = (SharedContextRecordList)cloneSchema();
180+
clone.updateVersion = updateVersion;
181+
return clone;
182+
}
183+
178184
public Record createRecord(){
179185
if(recordClass == null){
180186
SharedContextRecord record = new SharedContextRecord(recordSchema);
@@ -261,6 +267,14 @@ public SharedContextValueDifference updateRemove(int index, SharedContextValueDi
261267
return diff;
262268
}
263269

270+
/**
271+
* 指定されたレコードを削除した場合の差分情報を取得する。<p>
272+
*
273+
* @param record 削除するレコード
274+
* @param diff 差分
275+
* @return 差分
276+
* @exception SharedContextUpdateException 差分情報の取得に失敗した場合
277+
*/
264278
public SharedContextValueDifference updateRemove(Record record, SharedContextValueDifference diff) throws SharedContextUpdateException{
265279
if(diff == null){
266280
diff = new Difference();
@@ -271,6 +285,13 @@ public SharedContextValueDifference updateRemove(Record record, SharedContextVal
271285
return diff;
272286
}
273287

288+
/**
289+
* 全件削除の差分情報を取得する。<p>
290+
*
291+
* @param diff 差分
292+
* @return 差分
293+
* @exception SharedContextUpdateException 差分情報の取得に失敗した場合
294+
*/
274295
public SharedContextValueDifference updateClear(SharedContextValueDifference diff) throws SharedContextUpdateException{
275296
if(diff == null){
276297
diff = new Difference();

0 commit comments

Comments
 (0)