Skip to content

Commit 468009c

Browse files
GH-37 Reduce stored procedure public interface
1 parent e82b2bf commit 468009c

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/main/java/de/zalando/sprocwrapper/proxy/StoredProcedure.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public String getName() {
186186
return name;
187187
}
188188

189-
public Object[] getParams(final Object[] origParams, final Connection connection) {
189+
private Object[] getParams(final Object[] origParams, final Connection connection) {
190190
final Object[] ps = new Object[params.size()];
191191

192192
int i = 0;
@@ -207,10 +207,6 @@ public Object[] getParams(final Object[] origParams, final Connection connection
207207
return ps;
208208
}
209209

210-
public int[] getTypes() {
211-
return types;
212-
}
213-
214210
private static int[] createTypes(final List<StoredProcedureParameter> params) {
215211
int[] types = new int[params.size()];
216212
int i = 0;
@@ -220,7 +216,7 @@ private static int[] createTypes(final List<StoredProcedureParameter> params) {
220216
return types;
221217
}
222218

223-
public int getShardId(final Object[] objs) {
219+
private int getShardId(final Object[] objs) {
224220
if (shardKeyParameters.isEmpty()) {
225221
return shardStrategy.getShardId(null);
226222
}
@@ -245,10 +241,6 @@ public String getSqlParameterList() {
245241
return sqlParameterList;
246242
}
247243

248-
public String getQuery() {
249-
return query;
250-
}
251-
252244
private static String createSqlParameterList(final List<StoredProcedureParameter> params) {
253245
String s = "";
254246
boolean first = true;
@@ -476,7 +468,7 @@ public Object execute(final DataSourceProvider dp, final InvocationContext invoc
476468
}
477469

478470
// most common case: only one shard and no argument partitioning
479-
return executor.executeSProc(firstDs, getQuery(), paramValues.get(0), getTypes(), invocation, returnType);
471+
return executor.executeSProc(firstDs, query, paramValues.get(0), types, invocation, returnType);
480472
} else {
481473
Map<Integer, SameConnectionDatasource> transactionalDatasources = null;
482474
try {
@@ -561,12 +553,12 @@ private Object executeSequential(final DataSourceProvider dp, final InvocationCo
561553

562554
sprocResult = null;
563555
try {
564-
sprocResult = executor.executeSProc(shardDs, getQuery(), paramValues.get(i), getTypes(), invocation,
556+
sprocResult = executor.executeSProc(shardDs, query, paramValues.get(i), types, invocation,
565557
returnType);
566558
} catch (final Exception e) {
567559

568560
// remember all exceptions and go on
569-
exceptions.add("shardId: " + shardId + ", message: " + e.getMessage() + ", query: " + getQuery());
561+
exceptions.add("shardId: " + shardId + ", message: " + e.getMessage() + ", query: " + query);
570562
causes.put(shardId, e);
571563
}
572564

@@ -603,9 +595,9 @@ private Object executeInParallel(final DataSourceProvider dp, final InvocationCo
603595
final FutureTask<Object> task = new FutureTask<>(new Call(
604596
executor,
605597
shardDs,
606-
getQuery(),
598+
query,
607599
paramValues.get(i),
608-
getTypes(),
600+
types,
609601
invocation,
610602
returnType
611603
));
@@ -623,13 +615,13 @@ private Object executeInParallel(final DataSourceProvider dp, final InvocationCo
623615
} catch (final InterruptedException ex) {
624616

625617
// remember all exceptions and go on
626-
exceptions.add("got sharding execution exception: " + ex.getMessage() + ", query: " + getQuery());
618+
exceptions.add("got sharding execution exception: " + ex.getMessage() + ", query: " + query);
627619
causes.put(taskToFinish.getKey(), ex);
628620
} catch (final ExecutionException ex) {
629621

630622
// remember all exceptions and go on
631623
exceptions.add("got sharding execution exception: " + ex.getCause().getMessage() + ", query: "
632-
+ getQuery());
624+
+ query);
633625
causes.put(taskToFinish.getKey(), ex.getCause());
634626
}
635627

0 commit comments

Comments
 (0)