Coder Social home page Coder Social logo

nhibernate-shards's Introduction

darioquintana

nhibernate-shards's People

Contributors

darioquintana avatar ggeurts avatar gustavofranke avatar rjperes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nhibernate-shards's Issues

Sharding does not implement Future Queries

I'm converting my sessions to use sharded sessions based on a tenant model (explictly open a session factory and then the session from that). My future queries are throwing an error:

NHibernate.Shards.Session.ShardedSessionImpl+DelegatingSessionImpl requires to implement NHibernate.Impl.AbstractSessionImpl class to support future batch

Are there any plans to implement Future batch queries? I appreciate that it's not really appropriate for cross-shard queries but the shard-per-tenant model is common and there is nothing to stop future queries in that scenario.

My alternative is to get a real session instead...

I can see that the IShardedSession api has a "GetSessionForObject" that returns an ISession (but at this stage I don't have an associated object to use) and the ShardedSessionImpl class has a private AnySession (but not exposed) and an EstablishFor(IShard shard) method but the only way I can see to get a shard is to use the ShardedSessionImpl Shards property - knowing that I only have the one shard.

Can any of these methods be exposed via the interface? (e.g the EstablishFor and Shard method/property?)

Is there a better way to do this?

Shard selection based on business id

Hi,

I’m trying work out if there is a sharding strategy based on business key (customer id). I can see the round robin example but that doesn’t seem appropriate.

We are working with tenanted data.... so all entities in a session will belong to the same shard.... so conceptually when we create a session we want to say ‘create a session for customer X’ and the sharding framework will either know that X relates to shard Y or that X isn’t in a shard so it will assign one.

Is this available out of the box and I’ve missed it in the code?

Thanks

I need Cross Shard Assonciation - NHibernate.Shards.CrossShardAssociationException,

My works in a problem. https://github.com/mesutcakir/NHibernate-Shards?organization=mesutcakir&organization=mesutcakir

image

image

`İşlenmeyen Özel Durum: NHibernate.Shards.CrossShardAssociationException: Object of entity type 'NHibernate.Shards.Demo.Task' is on shard '0' but an associated object of type 'NHibernate.Shards.Demo.Project' is on shard '1'.
   konum: NHibernate.Shards.Session.ShardedSessionImpl.ThrowIfConflictingShardId(String entityName, ShardId shardId, KeyValuePair2 associatedShardId)
   konum: NHibernate.Shards.Session.ShardedSessionImpl.TryGetShardIdOfAssociatedObject(String entityName, Object entity, ShardId& result)
   konum: NHibernate.Shards.Session.ShardedSessionImpl.SelectShardIdForNewEntity(String entityName, Object entity)
   konum: NHibernate.Shards.Session.ShardedSessionImpl.Save(String entityName, Object obj)
   konum: NHibernate.Shards.Session.ShardedSessionImpl.Save(Object obj)
   konum: NHibernate.Shards.Demo.FirmBasedApp.CreateTask(ISession session, Project project, String name, DayBase dayBase)
   konum: NHibernate.Shards.Demo.FirmBasedApp.AddData()
   konum: NHibernate.Shards.Demo.FirmBasedApp.Run()
   konum: NHibernate.Shards.Demo.FirmBasedApp.Main(String[] args)
Press any key to continue . . .`

I search this referances. Virtual Shards - https://docs.jboss.org/hibernate/stable/shards/reference/en/html/shards-resharding.html

But not working. "System.Collections.Generic.KeyNotFoundException"

image

`var virtualShardMap = new Dictionary<short, short>
            {
                { 0, 0 },
                { 1, 0 },
                { 2, 0 },
                { 3, 0 }
            };
            return new ShardedConfiguration(prototypeConfig, shardConfigs, shardStrategyFactory, virtualShardMap);`

image

İşlenmeyen Özel Durum: System.Collections.Generic.KeyNotFoundException: Verilen anahtar sözlükte yoktu.
   konum: System.ThrowHelper.ThrowKeyNotFoundException()
   konum: System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   konum: NHibernate.Shards.ShardedConfiguration..ctor(Configuration prototypeConfiguration, IEnumerable`1 shardConfigs, IShardStrategyFactory shardStrategyFactory, Dictionary`2 virtualShardToShardMap)
   konum: NHibernate.Shards.Demo.FirmBasedApp.BuildShardedConfiguration()
   konum: NHibernate.Shards.Demo.FirmBasedApp.Run()
   konum: NHibernate.Shards.Demo.FirmBasedApp.Main(String[] args)
Press any key to continue . . .

NHibernate.Shards => ShardedConfiguration

image


if (virtualShardToShardMap.Count != 0)
{
    // build the map from shard to set of virtual shards
    shardToVirtualShardIdMap = new Dictionary<short, ICollection<ShardId>>();
    foreach (var pair in virtualShardToShardMap)
    {
        var set = shardToVirtualShardIdMap[(pair.Value)]; //**Problem Here.**
        // see if we already have a set of virtual shards
        if (set == null)
        {
             // we don't, so create it and add it to the map
             set = new HashSet<ShardId>();
             shardToVirtualShardIdMap.Add(pair.Value, set);
        }
        set.Add(new ShardId(pair.Key));
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.