Giter Site home page Giter Site logo

hazelcast / hazelcast-go-client Goto Github PK

View Code? Open in Web Editor NEW
186.0 52.0 56.0 3.94 MB

Hazelcast Go Client

Home Page: https://hazelcast.com/clients/go

License: Apache License 2.0

Go 99.43% Shell 0.54% Makefile 0.03%
hazelcast in-memory datagrid big-data clustering scalability distributed caching imdg hazelcast-client

hazelcast-go-client's Introduction

Hazelcast Go Client

Go Reference

Hazelcast is an open-source distributed in-memory data store and computation platform that provides a wide variety of distributed data structures and concurrency primitives.

Hazelcast Go client is a way to communicate with Hazelcast 4 and 5 clusters and access the cluster data.

Sample Code

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/hazelcast/hazelcast-go-client"
)

func main() {
	ctx := context.TODO()
	// create the client and connect to the cluster on localhost
	client, err := hazelcast.StartNewClient(ctx)
	if err != nil {
		log.Fatal(err)
	}
	// get a map
	people, err := client.GetMap(ctx, "people")
	if err != nil {
		log.Fatal(err)
	}
	personName := "Jane Doe"
	// set a value in the map
	if err = people.Set(ctx, personName, 30); err != nil {
		log.Fatal(err)
	}
	// get a value from the map
	age, err := people.Get(ctx, personName)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s is %d years old.\n", personName, age)
	// stop the client to release resources
	client.Shutdown(ctx)
}

Features

  • Distributed, partitioned and queryable in-memory key-value store implementation, called Map.
  • Additional data structures and simple messaging constructs such as Replicated Map, MultiMap, Queue, List, PNCounter, Set, Topic and others.
  • Support for serverless and traditional web service architectures with Unisocket and Smart operation modes.
  • Go context support for all distributed data structures.
  • SQL support (only on Hazelcast 5.x).
  • External smart client discovery.
  • Hazelcast Management Center integration.
  • Ability to listen to client lifecycle, cluster state, and distributed data structure events.
  • And more...

Install

Requirements:

  • Hazelcast Go client is compatible only with Hazelcast 4.x and 5.x.
  • We support two most recent releases of Go, currently 1.20 and up.

In your Go module enabled project, add a dependency to github.com/hazelcast/hazelcast-go-client:

# Depend on the latest release
$ go get github.com/hazelcast/hazelcast-go-client@latest

Quick Start

Hazelcast Go client requires a working Hazelcast cluster.

Check out our Get Started page for options.

Starting the Default Client

Start the client with the default Hazelcast host and port using hazelcast.StartNewClient, when Hazelcast is running on local with the default options:

ctx := context.TODO()
client, err := hazelcast.StartNewClient(ctx)
// handle client start error

Starting the Client with Given Options

Note that Config structs are not thread-safe. Complete creation of the configuration in a single goroutine.

// create the default configuration
config := hazelcast.Config{}
// optionally set member addresses manually
config.Cluster.Network.SetAddresses("member1.example.com:5701", "member2.example.com:5701")
// create and start the client with the configuration provider
client, err := hazelcast.StartNewClientWithConfig(ctx, config)
// handle client start error

Documentation

Hazelcast Go Client documentation is hosted at pkg.go.dev.

You can view the documentation locally by using godoc:

$ godoc -http=localhost:5500

godoc is not installed by default with the base Go distribution. Install it using:

$ go get -u golang.org/x/tools/...`

Support

Join us at Go Client channel or Hazelcast at Google Groups.

Running the tests

Currently, we support only Linux, MacOS and WSL (Windows Subsystem for Linux) for testing the client.

You need to have the following installed in order to run integration tests:

  • Java 8
  • Maven 3 or better
  • Bash
  • Make

Before running the tests, starts Hazelcast Remote Controller, which enables the test suite to create clusters:

# Start RC with Hazelcast Community features
$ ./rc.sh start

# Or, start RC with Hazelcast Enterprise features
$ HAZELCAST_ENTERPRISE_KEY=ENTERPRISE-KEY-HERE ./rc.sh start 

You can run the tests using one of the following approaches:

  • Run make test-all to run integration tests.
  • Run make test-all-race to run integration tests with race detection.
  • Run make test-cover to generate the coverage report and make view-cover to view the test coverage summary and generate an HTML report.

Testing the client with SSL support requires running the remote controller with Hazelcast Enterprise features. To enable SSL connections, add ENABLE_SSL=1 to environment variables, or prepend it to the make commands above.

In order to turn on verbose logging, add ENABLE_TRACE=1 to environment variables, or prepend it to the make commands above.

License

Apache 2 License.

Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.

Visit www.hazelcast.com for more information.

hazelcast-go-client's People

Contributors

alisengul53 avatar angelasimms avatar asimarslan avatar degerhz avatar dependabot[bot] avatar enozcan avatar gonnya avatar gulcesirvanci avatar halfvector avatar jackpgreen avatar martijndeheus avatar mehmettokgoz avatar mustafaiman avatar neilstevenson avatar nevzatseferoglu avatar puzpuzpuz avatar saittalhanisanci avatar semihbkgr avatar serdaro avatar srknzl avatar utku-caglayan avatar yuce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hazelcast-go-client's Issues

Change import paths to hazelcast.org

Import paths start with github.com/hazelcast right know. We decided that import paths should start with hazelcast.org instead. This may include also a keyword like goclient at the end of the address: hazelcast.org/goclient.

Since version control is deeply involved with package hierarchy in golang, we may have to define some redirections in hazelcast.org website.

Errors

We need to make the errors visible to users so that they can see what kind of errors will be returned etc.
Right now errors.go is in internal/common. We need to move it to a folder like core which contains external api.

Why does ILifecycle interface not support for Get/GetAll methods?

Below Interface does not support Get/GetAll when I try to get added lifecycle listeners

// ILifecycle is a lifecycle service for Hazelcast clients.
type ILifecycle interface {
	// AddListener adds a listener object to listen for lifecycle events.
	// AddListener returns the registrationId.
	AddListener(listener interface{}) string

	// RemoveListener removes lifecycle listener with the given registrationId.
	// RemoveListener returns true if the listener is removed successfully, false otherwise.
	RemoveListener(registrationId *string) bool
}

Client hangs when finding single member

Hi Team,

after below changes, our passing test TestSingleMemberConnection hangs and causes Test killed with quit: ran too long (10m0s).

https://hazelcast-l337.ci.cloudbees.com/view/Clients/job/go-client-it-test/90/changes
Summary:
fix data race in heartbeat and remove unused method (commit: 220f9c8) 
fix some bugs in invocation service (commit: ccd02bc) 
add more tests to cluster.go (commit: a096319)

Error listed if no maps

If client starts and cluster has no maps existing,
gives

2017/11/21 14:20:38 error while fetching cluster partition table!

Maps might be created by this client, and no pre-exist.

Initial Codecs

Generate ;

ClientMessageCodecTemplate --> ClientMethod1Codec, etc
MapCodecTemplate --> MapMethod1Codec, MapMethod2Codec etc
(EventResponseTemplate)
(ResponseTemplate)

Partition Service

We have the following functionalities in the partition service;

  • refreshing the partition table periodically.
  • getting owner address of a given partition id.
  • getting partition count.
  • shutting down the partition service.

Topic

  • Backport the related Hazelcast Java interface into go repo.
  • Document the interface GoDocs.
  • Generate the related proxy codecs of client protocol
  • Implement proxy and write unit tests
  • Write a sample for this proxy

Code samples for go-client

  • Hello World
  • Simple Map
  • Map Listener
  • Map predicate (predicate support and builtin predicates)
  • Identified Serialization
  • Portable Serialization
  • Custom Serializable
  • Global Serializable

Hazelcast Client Engine does not know Go client

Go client authenticate itself as "GO" but this type is not defined on hazelcast side.

com.hazelcast.core.ClientType Enum should have GO as new value.

com.hazelcast.nio.ConnectionType Enum have a GO_CLIENT similar to other client types.

There are some methods makes some conversions like com.hazelcast.client.impl.protocol.task.AuthenticationBaseMessageTask#setConnectionType(), these should have a go improvement.

IMap(basic operations)

Implementation of

type IMap interface {
	Put(key interface{}, value interface{}) (oldValue interface{}, err error)
	Get(key interface{}) (value interface{}, err error)
	Remove(key interface{}) (value interface{}, err error)
	RemoveIfSame(key interface{}, value interface{}) (ok bool, err error)
	Size() (size int32, err error)
	ContainsKey(key interface{}) (found bool, err error)
	ContainsValue(value interface{}) (found bool, err error)
	Clear() (err error)
	Delete(key interface{}) (err error)
	IsEmpty() (empty bool, err error)
	AddIndex(attributes *string, ordered bool) (err error)
	Evict(key interface{}) (bool, error)
	EvictAll() error
	Flush() error
	ForceUnlock(key interface{}) error
	Lock(key interface{}) error
	LockWithLeaseTime(key interface{}, lease int64, leaseTimeUnit time.Duration) error
	Unlock(key interface{}) error
	IsLocked(key interface{}) (bool, error)
	Replace(key interface{}, value interface{}) (interface{}, error)
	ReplaceIfSame(key interface{}, oldValue interface{}, newValue interface{}) (bool, error)
	Set(key interface{}, value interface{}) error
	SetWithTtl(key interface{}, value interface{}, ttl int64, ttlTimeUnit time.Duration) error
	PutIfAbsent(key interface{}, value interface{}) (oldValue interface{}, err error)
	PutAll(mp *map[interface{}]interface{}) error
	EntrySet() ([]IPair, error)
	TryLock(key interface{}) (bool, error)
	TryLockWithTimeout(key interface{}, timeout int64, timeoutTimeUnit time.Duration) (bool, error)
	TryLockWithTimeoutAndLease(key interface{}, timeout int64, timeoutTimeUnit time.Duration, lease int64, leaseTimeUnit time.Duration) (bool, error)
	TryPut(key interface{}, value interface{}) (ok bool, err error)
	TryRemove(key interface{}, timeout int64, timeoutTimeUnit time.Duration) (ok bool, err error)
	GetAll(keys []interface{}) ([]IPair, error)
	GetEntryView(key interface{}) (IEntryView, error)
	PutTransient(key interface{}, value interface{}, ttl int64, ttlTimeUnit time.Duration) (err error)
	AddEntryListener(listener interface{}, includeValue bool) (*string, error)
	AddEntryListenerToKey(listener interface{}, key interface{}, includeValue bool) (*string, error)
	RemoveEntryListener(registrationId *string) error
}

RingBuffer

  • Backport the related Hazelcast Java interface into go repo.
  • Document the interface GoDocs.
  • Generate the related proxy codecs of client protocol
  • Implement proxy and write unit tests
  • Write a sample for this proxy

Listener services

Implement the new smart listener service that client connects to each member and listens local events. See Java client implementation

List

  • Backport the related Hazelcast Java interface into go repo.
  • Document the interface GoDocs.
  • Generate the related proxy codecs of client protocol
  • Implement proxy and write unit tests
  • Write a sample for this proxy

When all Cluster members down member list size is not 0

Hi Team, below are logs for TestClientWhenClusterCompletelyGoOffAndOn

=== RUN   TestClientWhenClusterCompletelyGoOffAndOn
time="2018-01-12T19:34:04Z" level=info msg="[0/1] [hazelcast-go-it]: Starting "
time="2018-01-12T19:34:05Z" level=info msg="[1/1] [hazelcast-go-it]: Started "
2018/01/12 19:34:05 IP 172.19.0.3
time="2018-01-12T19:34:06Z" level=info msg="Setting scale hazelcast-go-it=3..."
2018/01/12 19:34:08 New State :  STARTING
2018/01/12 19:34:09 Registered membership listener with Id  7a385493-f09f-426a-96ea-b60b6b043fc4
2018/01/12 19:34:09 New State :  CONNECTED
2018/01/12 19:34:09 New State :  STARTED
2018/01/12 19:34:09 Number of members : 1
2018/01/12 19:34:11 Cluster size is not met, retrying actual 1, expected 3
2018/01/12 19:34:13 Cluster size is not met, retrying actual 1, expected 3
2018/01/12 19:34:15 Cluster size is not met, retrying actual 1, expected 3
2018/01/12 19:34:17 Cluster size is not met, retrying actual 1, expected 3
2018/01/12 19:34:19 Cluster size is not met, retrying actual 1, expected 3
2018/01/12 19:34:19 Cluster size actual 3, expected 3
time="2018-01-12T19:34:19Z" level=info msg="[1/1] [hazelcast-go-it]: Stopping "
2018/01/12 19:34:19 New State :  DISCONNECTED
2018/01/12 19:34:19 the following error occured while trying to connect to cluster:  target is disconnected
2018/01/12 19:34:19 the following error occured while trying to connect to cluster:  target is disconnected
2018/01/12 19:34:20 the following error occured while trying to connect to cluster:  packet is not sent
time="2018-01-12T19:34:20Z" level=info msg="[1/1] [hazelcast-go-it]: Stopped "
time="2018-01-12T19:34:20Z" level=info msg="[1/1] [hazelcast-go-it]: Deleting "
Network hz-go-it is external, skippingtime="2018-01-12T19:34:20Z" level=info msg="[1/1] [hazelcast-go-it]: Deleted "
2018/01/12 19:34:22 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:24 error while fetching cluster partition table!
2018/01/12 19:34:24 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:26 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:28 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:29 error while fetching cluster partition table!
2018/01/12 19:34:30 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:32 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:34 error while fetching cluster partition table!
2018/01/12 19:34:34 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:36 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:38 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:39 error while fetching cluster partition table!
2018/01/12 19:34:40 Cluster size is not met, retrying actual 3, expected 0
2018/01/12 19:34:40 Cluster size actual 3, expected 0
time="2018-01-12T19:34:40Z" level=info msg="[1/1] [hazelcast-go-it]: Starting "
time="2018-01-12T19:34:41Z" level=info msg="[2/1] [hazelcast-go-it]: Started "
2018/01/12 19:34:41 IP 172.19.0.3
time="2018-01-12T19:34:42Z" level=info msg="Setting scale hazelcast-go-it=2..."
2018/01/12 19:34:44 error while fetching cluster partition table!
2018/01/12 19:34:46 Cluster size is not met, retrying actual 3, expected 2
2018/01/12 19:34:48 Cluster size is not met, retrying actual 3, expected 2
2018/01/12 19:34:49 error while fetching cluster partition table!
2018/01/12 19:34:50 Cluster size is not met, retrying actual 3, expected 2
2018/01/12 19:34:52 Cluster size is not met, retrying actual 3, expected 2
2018/01/12 19:34:54 Cluster size is not met, retrying actual 3, expected 2
2018/01/12 19:34:54 Cluster size actual 2, expected 2
time="2018-01-12T19:34:54Z" level=info msg="[2/1] [hazelcast-go-it]: Stopping "
time="2018-01-12T19:34:55Z" level=info msg="[2/1] [hazelcast-go-it]: Stopped "
time="2018-01-12T19:34:55Z" level=info msg="[2/1] [hazelcast-go-it]: Deleting "
Network hz-go-it is external, skipping--- FAIL: TestClientWhenClusterCompletelyGoOffAndOn (51.10s)
        Error Trace:    acceptance.go:137
                        acceptance_test.go:46
        Error:          Not equal: 
                        expected: 0
                        actual  : 3
        Test:           TestClientWhenClusterCompletelyGoOffAndOn

Set

  • Backport the related Hazelcast Java interface into go repo.
  • Document the interface GoDocs.
  • Generate the related proxy codecs of client protocol
  • Implement proxy and write unit tests
  • Write a sample for this proxy

IMap predicate support

The following IMap operations should be implemented:

  • RemoveAll
  • KeySetWithPredicate
  • ValuesWithPredicate
  • EntrySetWithPredicate
  • AddEntryListenerWithPredicate
  • AddEntryListenerToKeyWithPredicate
  • ExecuteOnEntriesWithPredicate

Index out of range

If port is omitted, index out of range occurs

Fails:

func main() {
	clientConfig := hazelcast.NewHazelcastConfig()
	clientConfig.ClientNetworkConfig().AddAddress("127.0.0.1")
	client, _ := hazelcast.NewHazelcastClientWithConfig(clientConfig)
}

Works:

func main() {
	clientConfig := hazelcast.NewHazelcastConfig()
	clientConfig.ClientNetworkConfig().AddAddress("127.0.0.1:5701")
	client, _ := hazelcast.NewHazelcastClientWithConfig(clientConfig)
}

Member List

We should print the member list when the client connects to server.

ReplicatedMap

  • Backport the related Hazelcast Java interface into go repo.
  • Document the interface GoDocs.
  • Generate the related proxy codecs of client protocol
  • Implement proxy and write unit tests
  • Write a sample for this proxy

Invocation error when cluster scaled down

Hi Team, case steps are below
1] Scale Cluster to 3
2] Client member list size is 3
3] Put items to map
4] Scale Cluster to 2
5] Client member list size is not update to 2, remains as 3
6] Try to access map got below error


the following error occured while trying to send the invocation  ownerConnection is not active

=== RUN TestDataIntactWhenMembersDown
time="2018-01-06T18:39:47Z" level=info msg="[0/1] [hazelcast-go-it]: Starting "
time="2018-01-06T18:39:48Z" level=info msg="[1/1] [hazelcast-go-it]: Started "
2018/01/06 18:39:48 IP 172.19.0.3
time="2018-01-06T18:39:49Z" level=info msg="Setting scale hazelcast-go-it=3..."
2018/01/06 18:39:52 New State : STARTING
2018/01/06 18:39:53 Registered membership listener with Id 1d10a111-ed52-4252-8903-8f684cba70fc
2018/01/06 18:39:53 New State : CONNECTED
2018/01/06 18:39:53 New State : STARTED
2018/01/06 18:39:53 Number of members : 1
2018/01/06 18:39:55 Cluster size is not met, retrying actual 1, expected 3
2018/01/06 18:39:57 Cluster size is not met, retrying actual 1, expected 3
2018/01/06 18:39:59 Cluster size is not met, retrying actual 1, expected 3
2018/01/06 18:40:01 Cluster size is not met, retrying actual 1, expected 3
2018/01/06 18:40:03 Cluster size is not met, retrying actual 1, expected 3
2018/01/06 18:40:03 Cluster size actual 3, expected 3
time="2018-01-06T18:40:07Z" level=info msg="Setting scale hazelcast-go-it=2..."
2018/01/06 18:40:07 New State : DISCONNECTED
2018/01/06 18:40:08 error while fetching cluster partition table!
2018/01/06 18:40:10 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:12 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:13 error while fetching cluster partition table!
2018/01/06 18:40:14 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:16 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:18 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:18 error while fetching cluster partition table!
2018/01/06 18:40:20 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:22 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:23 error while fetching cluster partition table!
2018/01/06 18:40:24 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:26 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:28 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:28 error while fetching cluster partition table!
2018/01/06 18:40:30 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:32 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:33 error while fetching cluster partition table!
2018/01/06 18:40:34 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:36 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:38 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:38 error while fetching cluster partition table!
2018/01/06 18:40:40 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:42 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:43 error while fetching cluster partition table!
2018/01/06 18:40:44 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:46 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:48 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:48 error while fetching cluster partition table!
2018/01/06 18:40:50 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:52 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:53 error while fetching cluster partition table!
2018/01/06 18:40:54 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:56 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:58 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:40:58 error while fetching cluster partition table!
2018/01/06 18:41:00 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:41:02 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:41:03 error while fetching cluster partition table!
2018/01/06 18:41:04 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:41:06 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:41:08 Cluster size is not met, retrying actual 3, expected 2
2018/01/06 18:41:08 Cluster size actual 3, expected 2
2018/01/06 18:41:08 Key axsaqopfwdnghijhqdddhxeysbdwsktgicncoauonn
2018/01/06 18:41:08 the following error occured while trying to send the invocation ownerConnection is not active

  

GetMap fails with panic, regardless of err given in return assignment

Hi Team, I have below scenario and question

1] Client tries to connect with invalid credentials
2] Client returns proper error
3] However, in my sample code, I call GetMap as below afterwards, cluster size is 0

flow.createdMap, err = flow.client.GetMap(name); if err != nil {
			log.Printf("Error is %v", err)
			return flow
		}

It panics as below, does not it need to assign err?

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13fdd66]

goroutine 6 [running]:
testing.tRunner.func1(0xc42035c0f0)
        /usr/local/Cellar/go/1.9.2/libexec/src/testing/testing.go:711 +0x2d2
panic(0x14cd7e0, 0x1834d00)
        /usr/local/Cellar/go/1.9.2/libexec/src/runtime/panic.go:491 +0x283
github.com/hazelcast/go-client/internal/protocol.StringCalculateSize(...)
        /Users/baris/Go/src/github.com/hazelcast/go-client/internal/protocol/consts.go:28
github.com/hazelcast/go-client/internal/protocol.AddressCalculateSize(...)
        /Users/baris/Go/src/github.com/hazelcast/go-client/internal/protocol/consts.go:32
github.com/hazelcast/go-client/internal/protocol.ClientCreateProxyCalculateSize(...)
        /Users/baris/Go/src/github.com/hazelcast/go-client/internal/protocol/client_createproxy.go:25
github.com/hazelcast/go-client/internal/protocol.ClientCreateProxyEncodeRequest(0xc4201845f0, 0xc420184490, 0x0, 0xc420115080)
        /Users/baris/Go/src/github.com/hazelcast/go-client/internal/protocol/client_createproxy.go:31 +0x26
github.com/hazelcast/go-client/internal.(*ProxyManager).createProxy(0xc4201a1e00, 0xc420184490, 0xc4201845f0, 0x15, 0x1870700, 0xc420013800, 0x15)
        /Users/baris/Go/src/github.com/hazelcast/go-client/internal/proxy_manager.go:63 +0x51
github.com/hazelcast/go-client/internal.(*ProxyManager).GetOrCreateProxy(0xc4201a1e00, 0x157465a, 0x12, 0xc420164b96, 0x3, 0x0, 0x0, 0x0, 0x0)
        /Users/baris/Go/src/github.com/hazelcast/go-client/internal/proxy_manager.go:52 +0x254
github.com/hazelcast/go-client/internal.(*HazelcastClient).GetDistributedObject(0xc4202567e0, 0x157465a, 0x12, 0xc420164b96, 0x3, 0x143bb16, 0xc42021abc0, 0x2a, 0xc420164b96)
        /Users/baris/Go/src/github.com/hazelcast/go-client/internal/client.go:51 +0x5b
github.com/hazelcast/go-client/internal.(*HazelcastClient).GetMap(0xc4202567e0, 0xc420164b96, 0x3, 0xc420164b96, 0x3, 0x0, 0x0)
        /Users/baris/Go/src/github.com/hazelcast/go-client/internal/client.go:46 +0x58

IdGenerator backed by FlakeIDs

  • Backport the related Hazelcast Java interface into go repo.
  • Document the interface GoDocs.
  • Generate the related proxy codecs of client protocol
  • Implement proxy and write unit tests
  • Write a sample for this proxy

Client hangs when Cluster scaled down

Hi Team,
I have below flow:
1] Scale Hazelcast Cluster to 3
2] Client discovers all members
3] Put items to map
4] Scale Hazelcast Cluster to 1
5] Client can not detect new cluster size and hangs sporadically

Below is the log that I have:

2017/11/30 17:23:25 New State :  STARTING
2017/11/30 17:23:26 Registered membership listener with Id  df224d7f-c636-4870-9b8f-9f1fd413ade9
2017/11/30 17:23:26 New State :  CONNECTED
2017/11/30 17:23:26 New State :  STARTED
2017/11/30 17:23:26 Number of members : 1
2017/11/30 17:23:28 Cluster size is not met, retrying actual 1, expected 3
2017/11/30 17:23:30 Cluster size is not met, retrying actual 1, expected 3
2017/11/30 17:23:32 Cluster size is not met, retrying actual 1, expected 3
2017/11/30 17:23:34 Cluster size is not met, retrying actual 1, expected 3
2017/11/30 17:23:36 Cluster size is not met, retrying actual 1, expected 3
2017/11/30 17:23:36 Cluster size actual 3, expected 3
time="2017-11-30T17:23:43Z" level=info msg="Setting scale hazelcast=1..."
2017/11/30 17:23:43 New State :  DISCONNECTED
2017/11/30 17:23:43 the following error occured while trying to connect to cluster:  target is disconnected
2017/11/30 17:23:46 error while fetching cluster partition table!
2017/11/30 17:23:49 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:23:51 error while fetching cluster partition table!
2017/11/30 17:23:51 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:23:53 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:23:55 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:23:56 error while fetching cluster partition table!
2017/11/30 17:23:57 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:23:59 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:24:01 error while fetching cluster partition table!
2017/11/30 17:24:01 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:24:03 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:24:05 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:24:06 error while fetching cluster partition table!
2017/11/30 17:24:07 Cluster size is not met, retrying actual 3, expected 1
2017/11/30 17:24:07 Cluster size actual 3, expected 1
2017/11/30 17:24:11 error while fetching cluster partition table!
2017/11/30 17:24:16 error while fetching cluster partition table!
2017/11/30 17:24:21 error while fetching cluster partition table!
2017/11/30 17:24:26 error while fetching cluster partition table!
2017/11/30 17:24:31 error while fetching cluster partition table!
2017/11/30 17:24:36 error while fetching cluster partition table!
2017/11/30 17:24:41 error while fetching cluster partition table!
2017/11/30 17:24:46 error while fetching cluster partition table!
2017/11/30 17:24:51 error while fetching cluster partition table!
2017/11/30 17:24:56 error while fetching cluster partition table!
2017/11/30 17:25:01 error while fetching cluster partition table!
2017/11/30 17:25:06 error while fetching cluster partition table!
2017/11/30 17:25:11 error while fetching cluster partition table!
2017/11/30 17:25:16 error while fetching cluster partition table!
2017/11/30 17:25:21 error while fetching cluster partition table!
2017/11/30 17:25:26 error while fetching cluster partition table!
2017/11/30 17:25:31 error while fetching cluster partition table!
2017/11/30 17:25:36 error while fetching cluster partition table!
2017/11/30 17:25:41 error while fetching cluster partition table!
2017/11/30 17:25:46 error while fetching cluster partition table!
2017/11/30 17:25:51 error while fetching cluster partition table!
2017/11/30 17:25:56 error while fetching cluster partition table!
2017/11/30 17:25:57 the following error occured while trying to connect to cluster:  target is disconnected
2017/11/30 17:25:57 Heartbeat stopped for a connection  %!v(PANIC=interface conversion: interface {} is nil, not time.Time)
2017/11/30 17:26:01 error while fetching cluster partition table!
2017/11/30 17:26:06 error while fetching cluster partition table!
2017/11/30 17:26:11 error while fetching cluster partition table!
2017/11/30 17:26:16 error while fetching cluster partition table!
2017/11/30 17:26:21 error while fetching cluster partition table!
....

Queue

  • Backport the related Hazelcast Java interface into go repo.
  • Document the interface GoDocs.
  • Generate the related proxy codecs of client protocol
  • Implement proxy and write unit tests
  • Write a sample for this proxy

When member down, client connection attempt and timeout takes longer than expected

Hi Team,

1] Initially we have a connected member
2] Member goes down
3] we try to create map and insert items.

With below configuration and connection attempt limit, logs seems not correct.

config := hazelcast.NewHazelcastConfig()
config.ClientNetworkConfig().SetRedoOperation(true).SetConnectionAttemptLimit(1).SetInvocationTimeoutInSeconds(1)

and below logs:

2017/11/29 21:44:34 New State :  STARTING
2017/11/29 21:44:40 Registered membership listener with Id  25c30e87-7cd2-4bf0-887c-bcd520eaffe4
2017/11/29 21:44:40 New State :  CONNECTED
2017/11/29 21:44:40 New State :  STARTED            
2017/11/29 21:44:40 New State :  DISCONNECTED          
2017/11/29 21:44:45 error while fetching cluster partition table!
2017/11/29 21:44:50 error while fetching cluster partition table!
2017/11/29 21:44:55 error while fetching cluster partition table!
2017/11/29 21:45:00 error while fetching cluster partition table!
2017/11/29 21:45:05 error while fetching cluster partition table!
2017/11/29 21:45:10 error while fetching cluster partition table!
2017/11/29 21:45:15 error while fetching cluster partition table!
2017/11/29 21:45:20 error while fetching cluster partition table!
2017/11/29 21:45:25 error while fetching cluster partition table!
2017/11/29 21:45:30 error while fetching cluster partition table!
2017/11/29 21:45:35 error while fetching cluster partition table!
2017/11/29 21:45:40 error while fetching cluster partition table!
2017/11/29 21:45:45 error while fetching cluster partition table!
2017/11/29 21:45:50 error while fetching cluster partition table!
2017/11/29 21:45:55 error while fetching cluster partition table!
2017/11/29 21:45:55 the following error occured while trying to connect to cluster:  target is disconnected
2017/11/29 21:45:55 client will shutdown since it could not reconnect.
2017/11/29 21:45:55 New State :  SHUTTING_DOWN
2017/11/29 21:45:55 New State :  SHUTDOWN
2017/11/29 21:45:55 Error is client has been shutdown

Lifecycle services

  • CONNECTED : When Owner connection connected
  • DISCONNECTED : When Owner connection disconnected
  • STARTING : Lifecycle service started
  • STARTED: Client started all services
  • SHUTTING_DOWN : Lifecycle shutdown begin
  • SHUTDOWN : Lifecycle shutdown end

Error Handling

Errors will be handled in these packages:

  • serialization

  • internal

Builtin predicates

The following Predicates should be implemented:

  • Sql
  • And
  • Between
  • Equal
  • GreaterThan
  • GreaterEqual
  • LessThan
  • LessEqual
  • Like
  • ILike
  • In
  • InstanceOf
  • NotEqual
  • Not
  • Or
  • Regex
  • True
  • False

Proxy Manager

Proxy Manager methods will be implemented.

  • GetOrCreateProxy()

  • destroyProxy()

Proxies map is thread-safe.

KeySetWithPredicate fails when given Predicate is Regex

I have below code segment

        entrySet, err := flow.createdMap.EntrySetWithPredicate(core.Regex("this", valueRegex))
	...
	actualValues, err := flow.createdMap.ValuesWithPredicate(core.Regex("this", valueRegex))
	...
        keySet, err := flow.createdMap.KeySetWithPredicate(core.Regex("this", keyRegex))
       ...

It works for EntrySetWithPredicate, ValuesWithPredicate. However, KeySetWithPredicate returns empty keySet

Authentication

  • Basic authentication
  • Authentication error response handling
  • serialization level incompatibility

CRDT Counter

  • Backport the related Hazelcast Java interface into go repo.
  • Document the interface GoDocs.
  • Generate the related proxy codecs of client protocol
  • Implement proxy and write unit tests
  • Write a sample for this proxy

API Doc

API documentation of the below content:

  • config/config.go
  • core/ICluster.go
  • core/IDistributedObject.go
  • core/ILifecycle.go
  • core/IMap.go
  • hazelcast.go
  • core/api.go
  • core/predicates.go
  • serialization/api.go

MultiMap

  • Backport the related Hazelcast Java interface into go repo.
  • Document the interface GoDocs.
  • Generate the related proxy codecs of client protocol
  • Implement proxy and write unit tests
  • Write a sample for this proxy

build.sh script fails

o- missing execute permissions
o- line 28, "pushd" runs from wrong directory
o- missing dependent packages, such as "go2xunit"
(since we get "thrift" in this script, it should get all dependencies)

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.