<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:29 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-520] There is no way to chack master in java&apos;s client api when new Mongo(serverList) </title>
                <link>https://jira.mongodb.org/browse/JAVA-520</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Issure url:&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-519&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/JAVA-519&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We just want to check master in starting our web application.&lt;/p&gt;

&lt;p&gt;A full client code example:&lt;/p&gt;

&lt;p&gt;public class MongoDataSource {&lt;/p&gt;

&lt;p&gt;private static Logger log = LoggerFactory.getLogger(MongoDataSource.class);&lt;br/&gt;
private DB db;&lt;br/&gt;
private String dbName;&lt;br/&gt;
private Mongo mongo;&lt;br/&gt;
private String writeConcernName;&lt;br/&gt;
private WriteConcern writeConcern;&lt;br/&gt;
private boolean slaveOk;&lt;br/&gt;
private Set&amp;lt;String&amp;gt; hostNames = new HashSet&amp;lt;String&amp;gt;();&lt;br/&gt;
private List&amp;lt;ServerAddress&amp;gt; hosts = new ArrayList&amp;lt;ServerAddress&amp;gt;();&lt;br/&gt;
private boolean checkMaster;&lt;/p&gt;

&lt;p&gt;public MongoDataSource(String replicaHosts, String dbName, String writeConcernName, boolean slaveOk,boolean checkMaster){&lt;br/&gt;
String names[] = replicaHosts.split(&quot;,&quot;);&lt;br/&gt;
for (String name : names) &lt;/p&gt;
{ hostNames.add(name); }
&lt;p&gt;this.dbName = dbName;&lt;br/&gt;
this.writeConcernName = writeConcernName;&lt;br/&gt;
this.slaveOk = slaveOk;&lt;br/&gt;
this.checkMaster=checkMaster;&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;public void init() throws UnknownHostException, MongoException {&lt;br/&gt;
for (String hostName : hostNames) &lt;/p&gt;
{ String tmp[] = hostName.split(&quot;:&quot;); ServerAddress addr = new ServerAddress(tmp[0], Integer.parseInt(tmp[1])); hosts.add(addr); }
&lt;p&gt;mongo = new Mongo(hosts);&lt;br/&gt;
db = mongo.getDB(dbName);&lt;br/&gt;
WriteConcern wc = WriteConcern.valueOf(writeConcernName);&lt;br/&gt;
db.setWriteConcern(wc);&lt;br/&gt;
if (this.slaveOk) &lt;/p&gt;
{ db.slaveOk(); }
&lt;p&gt;if (checkMaster) &lt;/p&gt;
{ db.getCollectionNames(); }

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;public void destroy() &lt;/p&gt;
{ mongo.close(); }

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;configuration in spring xml file:&lt;br/&gt;
&amp;lt;bean id=&quot;mongods&quot; class=&quot;com.alibaba.cep.ep.dao.impl.MongoDataSource&quot; init-method=&quot;init&quot; destroy-method=&quot;destroy&quot;&amp;gt;&lt;br/&gt;
&amp;lt;constructor-arg value=&quot;10.20.30.56:11112&quot;&amp;gt;&amp;lt;/constructor-arg&amp;gt;&lt;br/&gt;
&amp;lt;constructor-arg value=&quot;db&quot;&amp;gt;&amp;lt;/constructor-arg&amp;gt;&lt;br/&gt;
&amp;lt;constructor-arg value=&quot;SAFE&quot;&amp;gt;&amp;lt;/constructor-arg&amp;gt;&lt;br/&gt;
&amp;lt;constructor-arg value=&quot;false&quot;&amp;gt;&amp;lt;/constructor-arg&amp;gt;&lt;br/&gt;
&amp;lt;constructor-arg value=&quot;true&quot;&amp;gt;&amp;lt;/constructor-arg&amp;gt;&lt;br/&gt;
&amp;lt;/bean&amp;gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="30489">JAVA-520</key>
            <summary>There is no way to chack master in java&apos;s client api when new Mongo(serverList) </summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="3">Duplicate</resolution>
                                        <assignee username="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="boringkiller">xfc</reporter>
                        <labels>
                            <label>api</label>
                            <label>check</label>
                            <label>client</label>
                            <label>java</label>
                            <label>master</label>
                            <label>mogodb</label>
                    </labels>
                <created>Mon, 13 Feb 2012 10:47:05 +0000</created>
                <updated>Tue, 25 Jun 2013 16:51:24 +0000</updated>
                            <resolved>Mon, 13 Feb 2012 12:35:08 +0000</resolved>
                                    <version>2.6.5</version>
                    <version>2.7.2</version>
                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                    <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="30408">JAVA-519</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhbc7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14637</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>