@@ -3315,6 +3315,7 @@ protected Map<String, ServiceInstanceInfo> getMap(Object[] arr) {
3315
3315
static final String KNOWN_SIZE_CXT_KEY = "tas.known_size" ;
3316
3316
static final String UNBALANCED_KEY = "mmesh.unbalanced" ;
3317
3317
static final String DEST_INST_ID_KEY = "tas.dest_iid" ;
3318
+ static final String VMODELID = "vmodelid" ;
3318
3319
3319
3320
// these are the possible values for the tas.internal context parameter
3320
3321
// it won't be set on requests from outside of the cluster, and will
@@ -3347,8 +3348,8 @@ public StatusInfo internalOperation(String modelId, boolean returnStatus, boolea
3347
3348
List <String > excludeInstances )
3348
3349
throws ModelNotFoundException , ModelLoadException , ModelNotHereException , InternalException {
3349
3350
try {
3350
- return (StatusInfo ) invokeModel (modelId , null , internalOpRemoteMeth ,
3351
- returnStatus , load , sync , lastUsed , excludeInstances ); // <-- "args"
3351
+ return (StatusInfo ) invokeModel (modelId , false , null ,
3352
+ internalOpRemoteMeth , returnStatus , load , sync , lastUsed , excludeInstances ); // <-- "args"
3352
3353
} catch (ModelNotFoundException | ModelLoadException | ModelNotHereException | InternalException e ) {
3353
3354
throw e ;
3354
3355
} catch (TException e ) {
@@ -3416,8 +3417,8 @@ public StatusInfo internalOperation(String modelId, boolean returnStatus, boolea
3416
3417
* @throws TException
3417
3418
*/
3418
3419
@ SuppressWarnings ("unchecked" )
3419
- protected Object invokeModel (final String modelId , final Method method , final Method remoteMeth ,
3420
- final Object ... args ) throws ModelNotFoundException , ModelNotHereException , ModelLoadException , TException {
3420
+ protected Object invokeModel (final String modelId , Boolean isVModel , final Method method ,
3421
+ final Method remoteMeth , final Object ... args ) throws ModelNotFoundException , ModelNotHereException , ModelLoadException , TException {
3421
3422
3422
3423
//verify parameter values
3423
3424
if (modelId == null || modelId .isEmpty ()) {
@@ -3430,6 +3431,10 @@ protected Object invokeModel(final String modelId, final Method method, final Me
3430
3431
}
3431
3432
3432
3433
final String tasInternal = contextMap .get (TAS_INTERNAL_CXT_KEY );
3434
+ String vModelId = "" ;
3435
+ if (isVModel ) {
3436
+ vModelId = contextMap .get (VMODELID );
3437
+ }
3433
3438
// Set the external request flag if it's not a tasInternal call or if
3434
3439
// tasInternal == INTERNAL_REQ. The latter is a new ensureLoaded
3435
3440
// invocation originating from within the cluster.
@@ -3502,7 +3507,7 @@ protected Object invokeModel(final String modelId, final Method method, final Me
3502
3507
throw new ModelNotHereException (instanceId , modelId );
3503
3508
}
3504
3509
try {
3505
- return invokeLocalModel (ce , method , args , modelId );
3510
+ return invokeLocalModel (ce , method , args , modelId , isVModel );
3506
3511
} catch (ModelLoadException mle ) {
3507
3512
mr = registry .get (modelId );
3508
3513
if (mr == null || !mr .loadFailedInInstance (instanceId )) {
@@ -3716,7 +3721,7 @@ protected Object invokeModel(final String modelId, final Method method, final Me
3716
3721
localInvokesInFlight .incrementAndGet ();
3717
3722
}
3718
3723
try {
3719
- Object result = invokeLocalModel (cacheEntry , method , args , modelId );
3724
+ Object result = invokeLocalModel (cacheEntry , method , args , modelId , isVModel );
3720
3725
return method == null && externalReq ? updateWithModelCopyInfo (result , mr ) : result ;
3721
3726
} finally {
3722
3727
if (!favourSelfForHits ) {
@@ -3936,7 +3941,7 @@ else if (mr.getInstanceIds().containsKey(instanceId)) {
3936
3941
3937
3942
// invoke model
3938
3943
try {
3939
- Object result = invokeLocalModel (cacheEntry , method , args , modelId );
3944
+ Object result = invokeLocalModel (cacheEntry , method , args , modelId , isVModel );
3940
3945
return method == null && externalReq ? updateWithModelCopyInfo (result , mr ) : result ;
3941
3946
} catch (ModelNotHereException e ) {
3942
3947
if (loadTargetFilter != null ) loadTargetFilter .remove (instanceId );
@@ -3989,10 +3994,9 @@ else if (mr.getInstanceIds().containsKey(instanceId)) {
3989
3994
throw t ;
3990
3995
} finally {
3991
3996
if (methodStartNanos > 0L && metrics .isEnabled ()) {
3992
- String [] extraLabels = new String []{modelId };
3993
3997
// only logged here in non-grpc (legacy) mode
3994
3998
metrics .logRequestMetrics (true , getRequestMethodName (method , args ),
3995
- nanoTime () - methodStartNanos , metricStatusCode , -1 , -1 , modelId , "" );
3999
+ nanoTime () - methodStartNanos , metricStatusCode , -1 , -1 , modelId , vModelId );
3996
4000
}
3997
4001
curThread .setName (threadNameBefore );
3998
4002
}
@@ -4122,13 +4126,15 @@ private Map<String, Long> filterIfReadOnly(Map<String, Long> instId) {
4122
4126
* instances inside and some out, and a request has been sent from outside the
4123
4127
* cluster to an instance inside (since it may land on an unintended instance in
4124
4128
* that case).
4125
- *
4129
+ * @param isVModel TODO
4130
+ * @throws TException TODO
4126
4131
* @throws ModelNotHereException if the specified destination instance isn't found
4127
4132
*/
4128
4133
protected Object forwardInvokeModel (String destId , String modelId , Method remoteMeth , Object ... args )
4129
4134
throws TException {
4130
4135
destinationInstance .set (destId );
4131
4136
try {
4137
+ //TODO: not sure what is happening here.. do I need to pass vmodelid to the remoteMeth.invoke?
4132
4138
return remoteMeth .invoke (directClient , ObjectArrays .concat (modelId , args ));
4133
4139
} catch (Exception e ) {
4134
4140
if (e instanceof InvocationTargetException ) {
@@ -4404,17 +4410,17 @@ protected Object invokeRemoteModel(BaseModelMeshService.Iface client, Method met
4404
4410
return remoteMeth .invoke (client , ObjectArrays .concat (modelId , args ));
4405
4411
}
4406
4412
4407
- protected Object invokeLocalModel (CacheEntry <?> ce , Method method , Object [] args , String modelId )
4413
+ protected Object invokeLocalModel (CacheEntry <?> ce , Method method , Object [] args , String modelId , Boolean isVModel )
4408
4414
throws InterruptedException , TException {
4409
- Object result = invokeLocalModel (ce , method , args );
4415
+ Object result = invokeLocalModel (ce , method , false , args );
4410
4416
// if this is an ensure-loaded request, check-for and trigger a "chained" load if necessary
4411
4417
if (method == null ) {
4412
4418
triggerChainedLoadIfNecessary (modelId , result , args , ce .getWeight (), null );
4413
4419
}
4414
4420
return result ;
4415
4421
}
4416
4422
4417
- private Object invokeLocalModel (CacheEntry <?> ce , Method method , Object [] args )
4423
+ private Object invokeLocalModel (CacheEntry <?> ce , Method method , Boolean isVModel , Object [] args )
4418
4424
throws InterruptedException , TException {
4419
4425
4420
4426
if (method == null ) {
@@ -4429,7 +4435,11 @@ private Object invokeLocalModel(CacheEntry<?> ce, Method method, Object[] args)
4429
4435
long now = currentTimeMillis ();
4430
4436
ce .upgradePriority (now + 3600_000L , now + 7200_000L ); // (2 hours in future)
4431
4437
}
4432
-
4438
+ Map <String , String > contextMap = ThreadContext .getCurrentContext ();
4439
+ String vModelId = null ;
4440
+ if (isVModel ) {
4441
+ vModelId = contextMap .get (VMODELID );
4442
+ }
4433
4443
// The future-waiting timeouts should not be needed, request threads are interrupted when their
4434
4444
// timeouts/deadlines expire, and the model loading thread that it waits for has its own timeout.
4435
4445
// But we still set a large one as a safeguard (there can be pathalogical cases where model-loading
@@ -4529,7 +4539,7 @@ private Object invokeLocalModel(CacheEntry<?> ce, Method method, Object[] args)
4529
4539
ce .afterInvoke (weight , tookNanos );
4530
4540
if (code != null && metrics .isEnabled ()) {
4531
4541
metrics .logRequestMetrics (false , getRequestMethodName (method , args ),
4532
- tookNanos , code , -1 , -1 , ce .modelId , "" );
4542
+ tookNanos , code , -1 , -1 , ce .modelId , vModelId );
4533
4543
}
4534
4544
}
4535
4545
}
0 commit comments