You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by luqmanahmad <lu...@gmail.com> on 2017/07/18 10:18:29 UTC
multiple thread access in segment resolver
Hi all,
Let say we have a segmentation resolver named
"ApplicationSegmentationResolver" which is checking about the statuses of
different applications but it needs to be initialised first time. For
example something like this:
public ApplicationSegmentationResolver implements SegmentationResolver {
Object status;
public boolean isValidSegment() throws IgniteCheckedException {
if (status == null) {
status = new Object();
// do some other stuff which needs to be initialised once
}
}
}
In the above scenario can multiple threads access this segmentation resolver
at the same time and see the status to null ? I am not sure how the
internals are working for segmentation resolver and is not clear from the
SegmentationResolver docs either, but if multiple threads can access it at
the same time is it a good thing to provide some kind of synchronisation ?
So that other threads can wait while it is being initialised ?
Thanks,
Luqman
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/multiple-thread-access-in-segment-resolver-tp15049.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: multiple thread access in segment resolver
Posted by luqmanahmad <lu...@gmail.com>.
Sounds good, thanks Andrew for your help.
On 18 Jul 2017 19:17, "Andrew Mashenkov [via Apache Ignite Users]" <
ml+s70518n15080h5@n6.nabble.com> wrote:
Hi,
Every node will have own SegmentationResolver and SegmentationProcessor
instances.
So, there is no need to be bothered about thread-safety.
On Tue, Jul 18, 2017 at 8:51 PM, luqmanahmad <[hidden email]
<http:///user/SendEmail.jtp?type=node&node=15080&i=0>> wrote:
> Hi Andrey,
>
> Shouldnt that need to be sync. The reason I am saying because what happens
> if two server nodes are started simultaneously on the same machine or on
> two different machines ? I think there would be some synchronisation
> needed. I could be wrong but could you please confirm that for me as the
> intialisation needs to be done once for us.
>
> Many thanks,
>
> Luqman
>
> On 18 Jul 2017 17:44, "Andrew Mashenkov [via Apache Ignite Users]" <[hidden
> email] <http:///user/SendEmail.jtp?type=node&node=15079&i=0>> wrote:
>
>> Hi Luqman,
>>
>> Please, take a look at internal class GridSegmentationProcessor and
>> where the only method isValidSegment() called from.
>> It is called on node start from single thread and then called from one of
>> discovery thread (SegmentCheckWorker).
>> Seems, there is no need any sync.
>>
>> SegmentationResolver is interface to allow user implement custom logic
>> that should be used by GridSegmentationProcessor.
>>
>>
>>
>> On Tue, Jul 18, 2017 at 1:18 PM, luqmanahmad <[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=15071&i=0>> wrote:
>>
>>> Hi all,
>>>
>>> Let say we have a segmentation resolver named
>>> "ApplicationSegmentationResolver" which is checking about the statuses
>>> of
>>> different applications but it needs to be initialised first time. For
>>> example something like this:
>>>
>>> public ApplicationSegmentationResolver implements SegmentationResolver {
>>>
>>> Object status;
>>>
>>> public boolean isValidSegment() throws IgniteCheckedException {
>>>
>>> if (status == null) {
>>> status = new Object();
>>> // do some other stuff which needs to be initialised once
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>> In the above scenario can multiple threads access this segmentation
>>> resolver
>>> at the same time and see the status to null ? I am not sure how the
>>> internals are working for segmentation resolver and is not clear from the
>>> SegmentationResolver docs either, but if multiple threads can access it
>>> at
>>> the same time is it a good thing to provide some kind of synchronisation
>>> ?
>>> So that other threads can wait while it is being initialised ?
>>>
>>> Thanks,
>>> Luqman
>>>
>>>
>>>
>>> --
>>> View this message in context: http://apache-ignite-users.705
>>> 18.x6.nabble.com/multiple-thread-access-in-segment-resolver-tp15049.html
>>> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>>>
>>
>>
>>
>> --
>> Best regards,
>> Andrey V. Mashenkov
>> Regards, Andrew.
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://apache-ignite-users.70518.x6.nabble.com/multiple-thre
>> ad-access-in-segment-resolver-tp15049p15071.html
>> To unsubscribe from multiple thread access in segment resolver, click
>> here.
>> NAML
>> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
> ------------------------------
> View this message in context: Re: multiple thread access in segment
> resolver
> <http://apache-ignite-users.70518.x6.nabble.com/multiple-thread-access-in-segment-resolver-tp15049p15079.html>
>
> Sent from the Apache Ignite Users mailing list archive
> <http://apache-ignite-users.70518.x6.nabble.com/> at Nabble.com.
>
--
Best regards,
Andrey V. Mashenkov
Regards, Andrew.
------------------------------
If you reply to this email, your message will be added to the discussion
below:
http://apache-ignite-users.70518.x6.nabble.com/multiple-
thread-access-in-segment-resolver-tp15049p15080.html
To unsubscribe from multiple thread access in segment resolver, click here
<http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=15049&code=bHVxbWFuYWhtZWRAZ21haWwuY29tfDE1MDQ5fC04NjE4NDY2OTY=>
.
NAML
<http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/multiple-thread-access-in-segment-resolver-tp15049p15081.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: multiple thread access in segment resolver
Posted by Andrey Mashenkov <an...@gmail.com>.
Hi,
Every node will have own SegmentationResolver and SegmentationProcessor
instances.
So, there is no need to be bothered about thread-safety.
On Tue, Jul 18, 2017 at 8:51 PM, luqmanahmad <lu...@gmail.com> wrote:
> Hi Andrey,
>
> Shouldnt that need to be sync. The reason I am saying because what happens
> if two server nodes are started simultaneously on the same machine or on
> two different machines ? I think there would be some synchronisation
> needed. I could be wrong but could you please confirm that for me as the
> intialisation needs to be done once for us.
>
> Many thanks,
>
> Luqman
>
> On 18 Jul 2017 17:44, "Andrew Mashenkov [via Apache Ignite Users]" <[hidden
> email] <http:///user/SendEmail.jtp?type=node&node=15079&i=0>> wrote:
>
>> Hi Luqman,
>>
>> Please, take a look at internal class GridSegmentationProcessor and
>> where the only method isValidSegment() called from.
>> It is called on node start from single thread and then called from one of
>> discovery thread (SegmentCheckWorker).
>> Seems, there is no need any sync.
>>
>> SegmentationResolver is interface to allow user implement custom logic
>> that should be used by GridSegmentationProcessor.
>>
>>
>>
>> On Tue, Jul 18, 2017 at 1:18 PM, luqmanahmad <[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=15071&i=0>> wrote:
>>
>>> Hi all,
>>>
>>> Let say we have a segmentation resolver named
>>> "ApplicationSegmentationResolver" which is checking about the statuses
>>> of
>>> different applications but it needs to be initialised first time. For
>>> example something like this:
>>>
>>> public ApplicationSegmentationResolver implements SegmentationResolver {
>>>
>>> Object status;
>>>
>>> public boolean isValidSegment() throws IgniteCheckedException {
>>>
>>> if (status == null) {
>>> status = new Object();
>>> // do some other stuff which needs to be initialised once
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>> In the above scenario can multiple threads access this segmentation
>>> resolver
>>> at the same time and see the status to null ? I am not sure how the
>>> internals are working for segmentation resolver and is not clear from the
>>> SegmentationResolver docs either, but if multiple threads can access it
>>> at
>>> the same time is it a good thing to provide some kind of synchronisation
>>> ?
>>> So that other threads can wait while it is being initialised ?
>>>
>>> Thanks,
>>> Luqman
>>>
>>>
>>>
>>> --
>>> View this message in context: http://apache-ignite-users.705
>>> 18.x6.nabble.com/multiple-thread-access-in-segment-resolver-tp15049.html
>>> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>>>
>>
>>
>>
>> --
>> Best regards,
>> Andrey V. Mashenkov
>> Regards, Andrew.
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://apache-ignite-users.70518.x6.nabble.com/multiple-thre
>> ad-access-in-segment-resolver-tp15049p15071.html
>> To unsubscribe from multiple thread access in segment resolver, click
>> here.
>> NAML
>> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
> ------------------------------
> View this message in context: Re: multiple thread access in segment
> resolver
> <http://apache-ignite-users.70518.x6.nabble.com/multiple-thread-access-in-segment-resolver-tp15049p15079.html>
> Sent from the Apache Ignite Users mailing list archive
> <http://apache-ignite-users.70518.x6.nabble.com/> at Nabble.com.
>
--
Best regards,
Andrey V. Mashenkov
Re: multiple thread access in segment resolver
Posted by luqmanahmad <lu...@gmail.com>.
Hi Andrey,
Shouldnt that need to be sync. The reason I am saying because what happens
if two server nodes are started simultaneously on the same machine or on
two different machines ? I think there would be some synchronisation
needed. I could be wrong but could you please confirm that for me as the
intialisation needs to be done once for us.
Many thanks,
Luqman
On 18 Jul 2017 17:44, "Andrew Mashenkov [via Apache Ignite Users]" <
ml+s70518n15071h26@n6.nabble.com> wrote:
> Hi Luqman,
>
> Please, take a look at internal class GridSegmentationProcessor and where
> the only method isValidSegment() called from.
> It is called on node start from single thread and then called from one of
> discovery thread (SegmentCheckWorker).
> Seems, there is no need any sync.
>
> SegmentationResolver is interface to allow user implement custom logic
> that should be used by GridSegmentationProcessor.
>
>
>
> On Tue, Jul 18, 2017 at 1:18 PM, luqmanahmad <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=15071&i=0>> wrote:
>
>> Hi all,
>>
>> Let say we have a segmentation resolver named
>> "ApplicationSegmentationResolver" which is checking about the statuses of
>> different applications but it needs to be initialised first time. For
>> example something like this:
>>
>> public ApplicationSegmentationResolver implements SegmentationResolver {
>>
>> Object status;
>>
>> public boolean isValidSegment() throws IgniteCheckedException {
>>
>> if (status == null) {
>> status = new Object();
>> // do some other stuff which needs to be initialised once
>> }
>>
>> }
>>
>> }
>>
>> In the above scenario can multiple threads access this segmentation
>> resolver
>> at the same time and see the status to null ? I am not sure how the
>> internals are working for segmentation resolver and is not clear from the
>> SegmentationResolver docs either, but if multiple threads can access it at
>> the same time is it a good thing to provide some kind of synchronisation ?
>> So that other threads can wait while it is being initialised ?
>>
>> Thanks,
>> Luqman
>>
>>
>>
>> --
>> View this message in context: http://apache-ignite-users.705
>> 18.x6.nabble.com/multiple-thread-access-in-segment-resolver-tp15049.html
>> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
> Regards, Andrew.
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-ignite-users.70518.x6.nabble.com/multiple-
> thread-access-in-segment-resolver-tp15049p15071.html
> To unsubscribe from multiple thread access in segment resolver, click here
> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=15049&code=bHVxbWFuYWhtZWRAZ21haWwuY29tfDE1MDQ5fC04NjE4NDY2OTY=>
> .
> NAML
> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/multiple-thread-access-in-segment-resolver-tp15049p15079.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: multiple thread access in segment resolver
Posted by Andrey Mashenkov <an...@gmail.com>.
Hi Luqman,
Please, take a look at internal class GridSegmentationProcessor and where
the only method isValidSegment() called from.
It is called on node start from single thread and then called from one of
discovery thread (SegmentCheckWorker).
Seems, there is no need any sync.
SegmentationResolver is interface to allow user implement custom logic that
should be used by GridSegmentationProcessor.
On Tue, Jul 18, 2017 at 1:18 PM, luqmanahmad <lu...@gmail.com> wrote:
> Hi all,
>
> Let say we have a segmentation resolver named
> "ApplicationSegmentationResolver" which is checking about the statuses of
> different applications but it needs to be initialised first time. For
> example something like this:
>
> public ApplicationSegmentationResolver implements SegmentationResolver {
>
> Object status;
>
> public boolean isValidSegment() throws IgniteCheckedException {
>
> if (status == null) {
> status = new Object();
> // do some other stuff which needs to be initialised once
> }
>
> }
>
> }
>
> In the above scenario can multiple threads access this segmentation
> resolver
> at the same time and see the status to null ? I am not sure how the
> internals are working for segmentation resolver and is not clear from the
> SegmentationResolver docs either, but if multiple threads can access it at
> the same time is it a good thing to provide some kind of synchronisation ?
> So that other threads can wait while it is being initialised ?
>
> Thanks,
> Luqman
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/multiple-thread-access-in-segment-
> resolver-tp15049.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>
--
Best regards,
Andrey V. Mashenkov