44import com .squareup .okhttp .Call ;
55import io .kubernetes .client .*;
66import io .kubernetes .client .informer .impl .DefaultSharedIndexInformer ;
7+ import io .kubernetes .client .util .CallGenerator ;
78import io .kubernetes .client .util .CallGeneratorParams ;
89import io .kubernetes .client .util .Watch ;
910import io .kubernetes .client .util .common .Collections ;
1314import java .util .concurrent .ExecutorService ;
1415import java .util .concurrent .Executors ;
1516import java .util .concurrent .Future ;
16- import java .util .function .Function ;
1717
1818/** SharedInformerFactory class constructs and caches informers for api types. */
1919public class SharedInformerFactory {
@@ -51,7 +51,7 @@ public SharedInformerFactory(ExecutorService threadPool) {
5151 * @return the shared index informer
5252 */
5353 public synchronized <ApiType , ApiListType > SharedIndexInformer <ApiType > sharedIndexInformerFor (
54- Function < CallGeneratorParams , Call > callGenerator ,
54+ CallGenerator callGenerator ,
5555 Class <ApiType > apiTypeClass ,
5656 Class <ApiListType > apiListTypeClass ) {
5757 return sharedIndexInformerFor (callGenerator , apiTypeClass , apiListTypeClass , 0 );
@@ -70,7 +70,7 @@ public synchronized <ApiType, ApiListType> SharedIndexInformer<ApiType> sharedIn
7070 * @return the shared index informer
7171 */
7272 public synchronized <ApiType , ApiListType > SharedIndexInformer <ApiType > sharedIndexInformerFor (
73- Function < CallGeneratorParams , Call > callGenerator ,
73+ CallGenerator callGenerator ,
7474 Class <ApiType > apiTypeClass ,
7575 Class <ApiListType > apiListTypeClass ,
7676 long resyncPeriodInMillis ) {
@@ -84,20 +84,20 @@ public synchronized <ApiType, ApiListType> SharedIndexInformer<ApiType> sharedIn
8484 }
8585
8686 private <ApiType , ApiListType > ListerWatcher <ApiType , ApiListType > listerWatcherFor (
87- Function < CallGeneratorParams , Call > callGenerator ,
87+ CallGenerator callGenerator ,
8888 Class <ApiType > apiTypeClass ,
8989 Class <ApiListType > apiListTypeClass ) {
9090 ApiClient apiClient = Configuration .getDefaultApiClient ();
9191 return new ListerWatcher <ApiType , ApiListType >() {
9292 @ Override
9393 public ApiListType list (CallGeneratorParams params ) throws ApiException {
94- Call call = callGenerator .apply (params );
94+ Call call = callGenerator .generate (params );
9595 return (ApiListType ) apiClient .execute (call , apiListTypeClass ).getData ();
9696 }
9797
9898 @ Override
9999 public Watch <ApiType > watch (CallGeneratorParams params ) throws ApiException {
100- Call call = callGenerator .apply (params );
100+ Call call = callGenerator .generate (params );
101101 return Watch .createWatch (
102102 apiClient ,
103103 call ,
@@ -106,6 +106,19 @@ public Watch<ApiType> watch(CallGeneratorParams params) throws ApiException {
106106 };
107107 }
108108
109+ /**
110+ * Gets existing shared index informer, return null if the requesting informer is never
111+ * constructed.
112+ *
113+ * @param <ApiType> the type parameter
114+ * @param apiTypeClass the api type class
115+ * @return the existing shared index informer
116+ */
117+ public synchronized <ApiType > SharedIndexInformer <ApiType > getExistingSharedIndexInformer (
118+ Class <ApiType > apiTypeClass ) {
119+ return this .informers .get (TypeToken .get (apiTypeClass ).getType ());
120+ }
121+
109122 /** Start all registered informers. */
110123 public synchronized void startAllRegisteredInformers () {
111124 if (Collections .isEmptyMap (informers )) {
0 commit comments