Thank you for explaining Pavel. Didn’t know this.
Found this workaround more or less by accident. Jay From: Pavel Tupitsyn <[email protected]> Sent: Tuesday, 24 January 2023 06:32 To: [email protected] Subject: Re: ScanQuery and PeerAssemblyLoading - Issue 1 Jay, Peer Assembly Loading feature only exists for Compute API. - When you perform a ScanQuery the 1st time, the assembly does not exist on the remote node and you get an error. - After you run a Compute task, your entire assembly (including SalaryFilter class) gets loaded on the remote node, and now this class can be used for ScanQuery too. Basically, Compute can be used as a workaround to pre-load any assemblies on remote nodes. Pavel On Mon, Jan 23, 2023 at 8:29 PM <[email protected] <mailto:[email protected]> > wrote: Dear Community, I’ve done quite a lot of testing and somehow remotely loading a cache entry filter from client to server only works after a compute-call was made. This appears somewhat strange – maybe someone can explain (/or reproduce the behaviour? Full code at the end of this mail). The setup: Ignite 2.14 with PeerAssemblyLoadingMode.CurrentAppDomain; .NET 5.0 with incremental assembly versioning; (Thick) .NET client running queries against a .NET-embedded server. Summary of the client code: - Create a cache and put some users - Run ScanQuery (1st time) -> Exception “No matching type found for object [typeId=327128514, typeName=SalaryFilter]. This usually indicates that assembly with specified type is not loaded on a node.” - Run (any) compute task - Run ScanQuery (2nd time) -> Works Same behaviour can be observed when restarting / recompiling in-between any of the above stages, repeating stages multiple times, and so on. Thank you for any input on this. Jay SERVER CODE: public static class Program { public static async Task Main(string[] args) { IgniteConfiguration IgniteConfig = new IgniteConfiguration(); IgniteConfig.PeerAssemblyLoadingMode = PeerAssemblyLoadingMode.CurrentAppDomain; var ignite = Ignition.Start(IgniteConfig); ignite.GetCluster().SetActive(true); Console.ReadLine(); } } CLIENT CODE: public static class Program { public static async Task Main(string[] args) { IgniteConfiguration IgniteConfig = new IgniteConfiguration(); IgniteConfig.PeerAssemblyLoadingMode = PeerAssemblyLoadingMode.CurrentAppDomain; IgniteConfig.ClientMode = true; var ignite = Ignition.Start(IgniteConfig); var cache = ignite.GetOrCreateCache<string, IBinaryObject>("Name_User_Cache").WithKeepBinary<string, IBinaryObject>(); IBinaryObjectBuilder builder = ignite.GetBinary().GetBuilder("User"); IBinaryObject user = builder.SetField<int>("Salary", 1001).Build(); cache.Put("First User", user); user = builder.SetField<int>("Salary", 1000).Build(); cache.Put("Second User", user); user = builder.SetField<int>("Salary", 1002).Build(); cache.Put("Third User", user); Console.WriteLine("First search:"); RunScanQuery(cache); Console.WriteLine("Broadcasting compute job"); ignite.GetCompute().Broadcast(new HelloAction()); Console.WriteLine("Second search:"); RunScanQuery(cache); Console.ReadLine(); } static void RunScanQuery(ICache<string, IBinaryObject> cache) { try { using (var cursor = cache.Query(new ScanQuery<string, IBinaryObject>(new SalaryFilter()))) { foreach (var entry in cursor) { Console.WriteLine("Key = " + entry.Key + ", Value.Salary = " + entry.Value.GetField<int>("Salary").ToString()); } } } catch (Exception ex) { Console.WriteLine("Exception: " + ex.Message); } } } class HelloAction : IComputeAction { public void Invoke() { Console.WriteLine("Hello, World!"); } } class SalaryFilter : ICacheEntryFilter<string, IBinaryObject> { public bool Invoke(ICacheEntry<string, IBinaryObject> entry) { return entry.Value.GetField<int>("Salary") > 1000; } } appreciate the help
