Thread View: news.software.nntp
10 messages
10 total messages
Started by Thufir Hawat
Sat, 16 Feb 2013 09:28
NNTP API (Java)
Author: Thufir Hawat
Date: Sat, 16 Feb 2013 09:28
Date: Sat, 16 Feb 2013 09:28
67 lines
3680 bytes
3680 bytes
I'm not quite understanding the NNTP protocol as it relates to article
numbers upstream and downstream. I'm using Java at the moment.
Using the GNU NNTP API:
http://www.gnu.org/software/classpathx/javamail/
it seems that there's no method for getting new articles for a given
group. While there's a method for seeing whether there are new messages:
http://www.gnu.org/software/classpathx/javamail/javadoc/gnu/mail/
providers/nntp/NNTPFolder.html#hasNewMessages%28%29
it returns only a boolean. Java snippet:
NNTPStore ns = (NNTPStore) store;
boolean hasNew = false;
synchronized (ns.connection)
{
GroupResponse response = ns.connection.group(name);
if (response.last > last)
{
hasNew = true;
}
count = response.count;
first = response.first;
last = response.last;
}
return hasNew;
http://cvs.savannah.gnu.org/viewvc/*checkout*/mail/source/gnu/mail/
providers/nntp/NNTPFolder.java?root=classpathx&content-type=text%2Fplain
So, it seems like what's really needed is the value of response.last, and
then anything, err, ?greater? than response.last (for the message ID int)
should be what's fetched.
I'm confused.
When leafnode gets NNTP articles, it does something like:
news.software.nntp: skipping articles 1-27275 inclusive (initial limit)
news.software.nntp: considering articles 27276 - 27284
so it's using some logic to determine the article number to request, and
then requests a range. Can someone explain a bit the mechanics of how a
downstream "client" knows what range of articles to ask for from the
upstream "server"? I'm running leafnode, which *is* a server (I think),
so the nomenclature throws me a bit there.
My concern is that the "id" isn't reliable:
"Note that the message number for a particular Message can change during
a session if other messages in the Folder are deleted and expunged."
http://docs.oracle.com/javaee/6/api/javax/mail/
Message.html#getMessageNumber%28%29
which is what the GNU is basing their NNTP client upon. I suppose it's
not the message number for a message which has been downloaded already,
it's the message number on the "server" upstream which matters!?
thanks,
Thufir
Re: NNTP API (Java)
Author: Jeffrey M. Vinocur
Date: Sat, 16 Feb 2013 22:15
Date: Sat, 16 Feb 2013 22:15
54 lines
3167 bytes
3167 bytes
In article <j204v9-5j2.ln1@dur.bounceme.net>, Thufir Hawat <hawat.thufir@gmail.com> wrote: >I'm not quite understanding the NNTP protocol as it relates to article >numbers upstream and downstream. I'm using Java at the moment. > >Using the GNU NNTP API: > >http://www.gnu.org/software/classpathx/javamail/ I'm not at all familiar with this, but from the code snippet and link you provided, I think this may not be a sufficiently sophisticated framework to be useful to you. >So, it seems like what's really needed is the value of response.last, and >then anything, err, ?greater? than response.last (for the message ID int) >should be what's fetched. Correct. If you don't know about RFC 3977, you probably should start there. >When leafnode gets NNTP articles, it does something like: > >news.software.nntp: skipping articles 1-27275 inclusive (initial limit) >news.software.nntp: considering articles 27276 - 27284 > >so it's using some logic to determine the article number to request, and >then requests a range. Can someone explain a bit the mechanics of how a >downstream "client" knows what range of articles to ask for from the >upstream "server"? I'm running leafnode, which *is* a server (I think), >so the nomenclature throws me a bit there. The client has to keep track (on its own) of what the highest article number it has seen for a given group, and then request whatever is above that. >My concern is that the "id" isn't reliable: > >"Note that the message number for a particular Message can change during >a session if other messages in the Folder are deleted and expunged." > >http://docs.oracle.com/javaee/6/api/javax/mail/ >Message.html#getMessageNumber%28%29 This is nonsense. It is fundamental to NNTP (see the RFC 3977 as I suggested above) that the article numbers are fixed, not only within a session, but for the long term (on a particular server). -- Jeffrey M. Vinocur jeff@litech.org
Re: NNTP API (Java)
Author: Joshua Cranmer 🐧
Date: Sun, 17 Feb 2013 04:45
Date: Sun, 17 Feb 2013 04:45
14 lines
2061 bytes
2061 bytes
On 2/16/2013 3:28 AM, Thufir Hawat wrote: > My concern is that the "id" isn't reliable: > > "Note that the message number for a particular Message can change during > a session if other messages in the Folder are deleted and expunged." This documentation quote is clearly concerning itself with IMAP (the verb "expunge" is a very clear keyword here), where message sequence numbers can change as messages are deleted. The message numbers in NNTP are closer in spirit to IMAP's UIDs in that they (almost) never change. -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
Re: NNTP API (Java)
Author: Thufir Hawat
Date: Sun, 17 Feb 2013 05:56
Date: Sun, 17 Feb 2013 05:56
47 lines
3290 bytes
3290 bytes
On Sat, 16 Feb 2013 22:45:29 -0600, Joshua Cranmer 🐧 wrote:
> On 2/16/2013 3:28 AM, Thufir Hawat wrote:
>> My concern is that the "id" isn't reliable:
>>
>> "Note that the message number for a particular Message can change
>> during a session if other messages in the Folder are deleted and
>> expunged."
>
> This documentation quote is clearly concerning itself with IMAP (the
> verb "expunge" is a very clear keyword here), where message sequence
> numbers can change as messages are deleted. The message numbers in NNTP
> are closer in spirit to IMAP's UIDs in that they (almost) never change.
My concern is that when the check for new articles runs:
GroupResponse response = ns.connection.group(name);
if (response.last > last)
that the variable "last" is a count of articles already downloaded.
Wheras response.last is the article number upstream, and so apples are
being compared to oranges. Perhaps the upstream server has purged
articles, or maybe articles downstream have been purged.
In concrete terms, let's say on day one the articles are numbered 1 to
1000 (no gaps) and articles numbered 900 to 1000 are fetched. Then 100
new articles are posted upstream, bringing the highest article number to
1100. However, let's say 50 articles expire, so there are now 1050
articles upstream, but the newest article for the group is numbered 1100.
How does the downstream ?client? now know to request 100 new articles,
and which ones? The downstream clients should request articles 1001 to
1100.
My concern is that the check for new articles (above) will see a *total*
of 1050 articles, conclude there are 50 new articles.
Granted, I need to test that in Java, just not quite sure how to proceed
with that testing. (I know this is verging more in Java and away from
NNTP.)
Are my concerns valid? Hopefully that was at least readable.
thanks,
Thufir
Re: NNTP API (Java)
Author: Jeffrey M. Vinocur
Date: Sun, 17 Feb 2013 14:06
Date: Sun, 17 Feb 2013 14:06
30 lines
2285 bytes
2285 bytes
In article <7186v9-6i2.ln1@dur.bounceme.net>, Thufir Hawat <hawat.thufir@gmail.com> wrote: > >In concrete terms, let's say on day one the articles are numbered 1 to >1000 (no gaps) and articles numbered 900 to 1000 are fetched. Then 100 >new articles are posted upstream, bringing the highest article number to >1100. However, let's say 50 articles expire, so there are now 1050 >articles upstream, but the newest article for the group is numbered 1100. > >How does the downstream ?client? now know to request 100 new articles, >and which ones? The downstream clients should request articles 1001 to >1100. Please please go read RFC 3977. You are being done a disservice by the unclear/misleading/incorrect information in this Java documentation. >My concern is that the check for new articles (above) will see a *total* >of 1050 articles, conclude there are 50 new articles. The number 1050 is irrelevant. The server will report the newest available article is number 1100, the client will try to download the new 100, and pay no attention to whatever has happened with articles it has already seen. -- Jeffrey M. Vinocur jeff@litech.org
Re: NNTP API (Java)
Author: Thufir Hawat
Date: Mon, 18 Feb 2013 12:13
Date: Mon, 18 Feb 2013 12:13
18 lines
1819 bytes
1819 bytes
On Sun, 17 Feb 2013 14:06:54 +0000, Jeffrey M. Vinocur wrote: > Please please go read RFC 3977. You are being done a disservice by the > unclear/misleading/incorrect information in this Java documentation. I asked the Java question here: http://stackoverflow.com/questions/14935984/ While I appreciate how NNTP is supposed to work, I'm not convinced that this API is counting articles in a consistent fashion. -Thufir
Re: NNTP API (Java)
Author: Whiskers
Date: Mon, 18 Feb 2013 17:58
Date: Mon, 18 Feb 2013 17:58
62 lines
3940 bytes
3940 bytes
On 2013-02-16, Thufir Hawat <hawat.thufir@gmail.com> wrote: > I'm not quite understanding the NNTP protocol as it relates to article > numbers upstream and downstream. I'm using Java at the moment. > > Using the GNU NNTP API: > > http://www.gnu.org/software/classpathx/javamail/ [...] > My concern is that the "id" isn't reliable: > > "Note that the message number for a particular Message can change during > a session if other messages in the Folder are deleted and expunged." > > http://docs.oracle.com/javaee/6/api/javax/mail/ > Message.html#getMessageNumber%28%29 > > which is what the GNU is basing their NNTP client upon. I suppose it's > not the message number for a message which has been downloaded already, > it's the message number on the "server" upstream which matters!? > > > thanks, > > Thufir NNTP has no concept of "folder" or "NNTPStore"; these seem to be local terms used within the JavaMail software you're using (and about which I know nothing). "Message number" seems to relate only to the items stored within a "folder" created by or for JavaMail. Newsgroup articles are identified in two ways. The Message-ID (or MID) is unique to each article, and should be generated in a form that complies with the NNTP and Usenet RFCs. Look at the Message-ID and References headers in the articles in this newsgroup to see what they look like. The article number is local to each news-server or news spool, and for each newsgroup carried. When a server or spool gets a new article (identified ny the Message-ID header), it is added to the spool for the newsgroup concerned with the next available local article number. Such local article numbers are almost never re-used. The exception is when an administrator decides to delete all the articles currently stored and start again from "article 1"; this might be to overcome a corrupted file system or database, or to avoid difficulties with software that can only handle article numbers below a certain size. Look at the Xref headers from your news-server to see what article numbers look like. Newsgroup clients usually keep track of which articles have been fetched from the upstream server simply by recording that server's article number for the article 'seen' most recently in each newsgroup. This record may take the form of a file for the upstream server concerned: eg slrn creates a file such as ~/.jnewsrc in the user's home directory; Leafnode creates a file such as /var/spool/news/leaf.node/news.individual.net for an upstream account with Individual.net. -- -- ^^^^^^^^^^ -- Whiskers -- ~~~~~~~~~~
Re: NNTP API (Java)
Author: Thufir Hawat
Date: Tue, 19 Feb 2013 02:48
Date: Tue, 19 Feb 2013 02:48
24 lines
2361 bytes
2361 bytes
On Mon, 18 Feb 2013 17:58:09 +0000, Whiskers wrote: > Newsgroup clients usually keep track of which articles have been fetched > from the upstream server simply by recording that server's article > number for the article 'seen' most recently in each newsgroup. This > record may take the form of a file for the upstream server concerned: eg > slrn creates a file such as ~/.jnewsrc in the user's home directory; > Leafnode creates a file such as > /var/spool/news/leaf.node/news.individual.net for an upstream account > with Individual.net. In this case, the GNU API encapsulates the article number in such a way that it's completely hidden. As there's no provision within the API to request articles by the article number (instead Message.messageNumber is used for this), I think I'm going to request an overly large range and then reject by duplicate Message-ID. Annoying as that is, it seems better than the Apache API. Definitely I'd be interested in thoughts or alternatives. -Thufir
Re: NNTP API (Java)
Author: Richard Kettlewell
Date: Tue, 19 Feb 2013 09:04
Date: Tue, 19 Feb 2013 09:04
17 lines
2128 bytes
2128 bytes
Thufir Hawat <hawat.thufir@gmail.com> writes: > In this case, the GNU API encapsulates the article number in such a > way that it's completely hidden. > > As there's no provision within the API to request articles by the > article number (instead Message.messageNumber is used for this), I > think I'm going to request an overly large range and then reject by > duplicate Message-ID. Annoying as that is, it seems better than the > Apache API. > > Definitely I'd be interested in thoughts or alternatives. Use some other API without fatal design flaws? Roll your own? -- http://www.greenend.org.uk/rjk/
Re: NNTP API (Java)
Author: Jeffrey M. Vinocur
Date: Tue, 19 Feb 2013 10:12
Date: Tue, 19 Feb 2013 10:12
20 lines
1766 bytes
1766 bytes
In article <87fw0sisiz.fsf@araminta.anjou.terraraq.org.uk>, Richard Kettlewell <rjk@greenend.org.uk> wrote: >Thufir Hawat <hawat.thufir@gmail.com> writes: > >> Definitely I'd be interested in thoughts or alternatives. > >Use some other API without fatal design flaws? >Roll your own? Agreed. I think this API is designed to mimic an IMAP interface where there is no state on the client, and is effectively useless for any other purpose. Without knowing what you are actually intendending, it is hard to make better suggestions. -- Jeffrey M. Vinocur jeff@litech.org
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads